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);