From aaf2b3939e918f1e74da6fca00d3ae5cc8604436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sun, 4 Nov 2007 09:36:18 +0000 Subject: [PATCH] add http_output_queue() - send a tcp_queue over HTTP connection and prepend it with correct HTTP headers --- http.c | 19 +++++++++++++++++++ http.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/http.c b/http.c index 4a7b3cdd..f8f2eb9c 100644 --- a/http.c +++ b/http.c @@ -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 */ diff --git a/http.h b/http.h index 36a5310b..b3d15189 100644 --- a/http.h +++ b/http.h @@ -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);