void http_transmit_thing(const char *content_type,
int is_static) {
+ lprintf(9, "http_transmit_thing(%s)%s\n",
+ content_type,
+ (is_static ? " (static)" : "")
+ );
output_headers(0, 0, 0, 0, 0, is_static);
hprintf("Content-type: %s\r\n"
close(fd);
-#ifndef TECH_PREVIEW
lprintf(9, "output_static('%s') %s\n", what, content_type);
-#endif
http_transmit_thing(content_type, 1);
}
if (yesbstr("force_close_session")) {
const StrBuf *Tmpl = sbstr("template");
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(ChrPtr(Tmpl), StrLength(Tmpl), NULL, NULL);
+ DoTemplate(ChrPtr(Tmpl), StrLength(Tmpl), NULL, NULL, 0);
end_burst();
}
/*
* Offer to make any page the user's "start page."
*/
-void offer_start_page(void) {
+void offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) {
wprintf("<a href=\"change_start_page?startpage=");
urlescputs(WC->this_page);
wprintf("\">");
wprintf("NO\n");
}
else {
+ memset(buf, 5, 0);
serv_puts("NOOP");
serv_getln(buf, sizeof buf);
if (buf[3] == '*') {
char buf[SIZ];
int a, nBackDots, nEmpty;
int ContentLength = 0;
- StrBuf *ContentType, *UrlLine;
+ StrBuf *ContentType = NULL;
+ StrBuf *UrlLine = NULL;
StrBuf *content = NULL;
const char *content_end = NULL;
char browser_host[256];
if ((follow_xff) &&
GetHash(HTTPHeaders, HKEY("X-FORWARDED-HOST"), &vLine) &&
(vLine != NULL)) {
- safestrncpy(WCC->http_host, &buf[18], sizeof WCC->http_host);
+ safestrncpy(WCC->http_host,
+ ChrPtr((StrBuf*)vLine),
+ sizeof WCC->http_host);
}
if (IsEmptyStr(WCC->http_host) &&
GetHash(HTTPHeaders, HKEY("HOST"), &vLine) &&
body_start = StrLength(content);
/** Read the entire input data at once. */
- client_read(&WCC->http_sock, content, ReadBuf, ContentLength);
+ client_read(&WCC->http_sock, content, ReadBuf, ContentLength + body_start);
if (!strncasecmp(ChrPtr(ContentType), "application/x-www-form-urlencoded", 33)) {
StrBufCutLeft(content, body_start);
}
-int ConditionalImportantMesage(WCTemplateToken *Tokens, void *Context)
+int ConditionalImportantMesage(WCTemplateToken *Tokens, void *Context, int ContextType)
{
struct wcsession *WCC = WC;
if (WCC != NULL)
return 0;
}
-void tmplput_importantmessage(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
+void tmplput_importantmessage(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
struct wcsession *WCC = WC;
}
}
-void tmplput_offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
-{
- offer_start_page();
-}
-
-
-int ConditionalBstr(WCTemplateToken *Tokens, void *Context)
+int ConditionalBstr(WCTemplateToken *Tokens, void *Context, int ContextType)
{
if(Tokens->nParameters == 1)
return HaveBstr(Tokens->Params[0]->Start,
Tokens->Params[1]->Start) == 0;
}
-void tmplput_bstr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
+void tmplput_bstr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
StrBufAppendBuf(Target,
SBstr(Tokens->Params[0]->Start,
WebcitAddUrlHandler(HKEY("mimepart"), view_mimepart, NEED_URL);
WebcitAddUrlHandler(HKEY("mimepart_download"), download_mimepart, NEED_URL);
WebcitAddUrlHandler(HKEY("diagnostics"), diagnostics, NEED_URL);
- RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage);
- RegisterConditional(HKEY("COND:BSTR"), 1, ConditionalBstr);
- RegisterNamespace("BSTR", 1, 2, tmplput_bstr);
- RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage);
- RegisterNamespace("OFFERSTARTPAGE", 0, 0, tmplput_offer_start_page);
+
+ RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage, CTX_NONE);
+ RegisterConditional(HKEY("COND:BSTR"), 1, ConditionalBstr, CTX_NONE);
+ RegisterNamespace("BSTR", 1, 2, tmplput_bstr, CTX_NONE);
+ RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, CTX_NONE);
+ RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, CTX_NONE);
}