add http_output_queue() - send a tcp_queue over HTTP connection and prepend it with correct HTTP headers

This commit is contained in:
Andreas Öman 2007-11-04 09:36:18 +00:00
parent 900c7f6fff
commit aaf2b3939e
2 changed files with 22 additions and 0 deletions

19
http.c
View file

@ -165,6 +165,25 @@ http_error(http_connection_t *hc, int error)
http_printf(hc, "%s", ret);
}
/**
* Send an HTTP OK and post data from a tcp queue
*/
void
http_output_queue(http_connection_t *hc, tcp_queue_t *tq, const char *content)
{
http_output_reply_header(hc, 200);
if(hc->hc_version >= HTTP_VERSION_1_0) {
http_printf(hc,
"Content-Type: %s\r\n"
"Content-Length: %d\r\n"
"\r\n",
content, tq->tq_depth);
}
tcp_output_queue(&hc->hc_tcp_session, NULL, tq);
}
/**
* HTTP GET
*/

3
http.h
View file

@ -87,6 +87,9 @@ void http_error(http_connection_t *hc, int error);
void http_output_reply_header(http_connection_t *hc, int rc);
void http_output_queue(http_connection_t *hc, tcp_queue_t *tq,
const char *content);
typedef int (http_callback_t)(http_connection_t *hc, const char *remain,
void *opaque);