summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_h1proto.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2019-08-26 18:29:00 +0300
committerIgor Sysoev <igor@sysoev.ru>2019-08-26 18:29:00 +0300
commite2abfaf381984b9c441555a3614336b64008c80d (patch)
tree7e0dab421f7e5588a7e350009d688771a04b321c /src/nxt_h1proto.c
parent129882413013adc803d855b3ba413b55882c4293 (diff)
downloadunit-e2abfaf381984b9c441555a3614336b64008c80d.tar.gz
unit-e2abfaf381984b9c441555a3614336b64008c80d.tar.bz2
Adding body handler to nxt_http_request_header_send().
Diffstat (limited to 'src/nxt_h1proto.c')
-rw-r--r--src/nxt_h1proto.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c
index a60bdb36..b8f62a88 100644
--- a/src/nxt_h1proto.c
+++ b/src/nxt_h1proto.c
@@ -45,7 +45,7 @@ static void nxt_h1p_conn_request_body_read(nxt_task_t *task, void *obj,
void *data);
static void nxt_h1p_request_local_addr(nxt_task_t *task, nxt_http_request_t *r);
static void nxt_h1p_request_header_send(nxt_task_t *task,
- nxt_http_request_t *r);
+ nxt_http_request_t *r, nxt_work_handler_t body_handler);
static void nxt_h1p_request_send(nxt_task_t *task, nxt_http_request_t *r,
nxt_buf_t *out);
static nxt_buf_t *nxt_h1p_chunk_create(nxt_task_t *task, nxt_http_request_t *r,
@@ -996,7 +996,8 @@ static const nxt_str_t nxt_http_server_error[] = {
#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 65536\r\n")
static void
-nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
+nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_work_handler_t body_handler)
{
u_char *p;
size_t size;
@@ -1079,6 +1080,7 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
if (http11) {
if (n != NXT_HTTP_NOT_MODIFIED
&& n != NXT_HTTP_NO_CONTENT
+ && body_handler != NULL
&& !h1p->websocket)
{
h1p->chunked = 1;
@@ -1165,6 +1167,19 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
c->write = header;
c->write_state = &nxt_h1p_request_send_state;
+ if (body_handler != NULL) {
+ /*
+ * The body handler will run before c->io->write() handler,
+ * because the latter was inqueued by nxt_conn_write()
+ * in engine->write_work_queue.
+ */
+ nxt_work_queue_add(&task->thread->engine->fast_work_queue,
+ body_handler, task, r, NULL);
+
+ } else {
+ header->next = nxt_http_buf_last(r);
+ }
+
nxt_conn_write(task->thread->engine, c);
if (h1p->websocket) {