X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fwebcit.c;h=8a0ba58a98cb1d31dac5b5d3b397f312beccfda1;hb=5249c9ab6b14efd4d0f92cb64afd78bff3f7e163;hp=98ae071dda84b8377a1f46cc086ae47f085a3b6b;hpb=bf746185b226656e7ab10cb3e7f5c9706dbf4cc0;p=citadel.git
diff --git a/webcit/webcit.c b/webcit/webcit.c
index 98ae071dd..8a0ba58a9 100644
--- a/webcit/webcit.c
+++ b/webcit/webcit.c
@@ -3,15 +3,10 @@
* persistent session to the Citadel server, handling HTTP WebCit requests as
* they arrive and presenting a user interface.
*
- * Copyright (c) 1996-2011 by the citadel.org team
+ * Copyright (c) 1996-2013 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
*/
#define SHOW_ME_VAPPEND_PRINTF
@@ -138,12 +133,7 @@ void wDumpContent(int print_standard_html_footer)
*/
void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
int do_htmlhead, /* 1 = output HTML
section and opener */
-
- int do_room_banner, /* 0=no, 1=yes,
- * 2 = I'm going to embed my own, so don't open the
- *
either.
- */
-
+ int do_room_banner, /* 1 = include the room banner and */
int unset_cookies, /* 1 = session is terminating, so unset the cookies */
int suppress_check, /* 1 = suppress check for instant messages */
int cache /* 1 = allow browser to cache this page */
@@ -151,7 +141,11 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
wcsession *WCC = WC;
char httpnow[128];
- hprintf("HTTP/1.1 200 OK\n");
+ if (WCC->Hdr->HaveRange > 1)
+ hprintf("HTTP/1.1 206 Partial Content\r\n");
+ else
+ hprintf("HTTP/1.1 200 OK\r\n");
+
http_datestring(httpnow, sizeof httpnow, time(NULL));
if (do_httpheaders) {
@@ -197,21 +191,21 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
if ( (WCC->logged_in) && (!unset_cookies) ) {
DoTemplate(HKEY("paging"), NULL, &NoCtx);
}
- if (do_room_banner == 1) {
+ if (do_room_banner) {
tmplput_roombanner(NULL, NULL);
}
}
- if (do_room_banner == 1) {
+ if (do_room_banner) {
wc_printf("
\n");
}
}
void output_custom_content_header(const char *ctype) {
- hprintf("HTTP/1.1 200 OK\r\n");
- hprintf("Content-type: %s; charset=utf-8\r\n",ctype);
- hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
- hprintf("Connection: close\r\n");
+ hprintf("HTTP/1.1 200 OK\r\n");
+ hprintf("Content-type: %s; charset=utf-8\r\n",ctype);
+ hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
+ hprintf("Connection: close\r\n");
}
@@ -234,12 +228,16 @@ void http_redirect(const char *whichpage) {
/*
- * Output a piece of content to the web browser using conformant HTTP and MIME semantics
+ * Output a piece of content to the web browser using conformant HTTP and MIME semantics.
+ *
+ * If this function is called, it is expected that begin_burst() has already been called
+ * and some sort of content has been fed into the buffer. This function will transmit a
+ * bunch of headers to the client. end_burst() will add some headers of its own, and then
+ * transmit the buffered content to the client.
*/
void http_transmit_thing(const char *content_type, int is_static)
{
-
- syslog(9, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
+ syslog(LOG_DEBUG, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
output_headers(0, 0, 0, 0, 0, is_static);
hprintf("Content-type: %s\r\n"
@@ -251,6 +249,30 @@ void http_transmit_thing(const char *content_type, int is_static)
end_burst();
}
+void http_transmit_headers(const char *content_type, int is_static, long is_chunked, int is_gzip)
+{
+ wcsession *WCC = WC;
+ syslog(LOG_DEBUG, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
+ output_headers(0, 0, 0, 0, 0, is_static);
+
+ if (is_gzip)
+ hprintf("Content-encoding: gzip\r\n");
+
+ if (WCC->Hdr->HaveRange)
+ hprintf("Accept-Ranges: bytes\r\n"
+ "Content-Range: bytes %ld-%ld/%ld\r\n",
+ WCC->Hdr->RangeStart,
+ WCC->Hdr->RangeTil,
+ WCC->Hdr->TotalBytes);
+
+ hprintf("Content-type: %s\r\n"
+ "Server: "PACKAGE_STRING"\r\n"
+ "%s"
+ "Connection: close\r\n\r\n",
+ content_type,
+ (is_chunked)?"Transfer-Encoding: chunked\r\n":"");
+}
+
/*
* Convenience functions to display a page containing only a string
@@ -262,14 +284,13 @@ void http_transmit_thing(const char *content_type, int is_static)
void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext)
{
hprintf("HTTP/1.1 200 OK\n");
- output_headers(1, 1, 2, 0, 0, 0);
- wc_printf("