summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/nxt_h1proto.c12
-rw-r--r--src/nxt_http.h9
-rw-r--r--src/nxt_http_error.c4
-rw-r--r--src/nxt_http_proxy.c4
-rw-r--r--src/nxt_http_request.c5
-rw-r--r--src/nxt_http_return.c2
-rw-r--r--src/nxt_http_static.c9
-rw-r--r--src/nxt_router.c3
8 files changed, 24 insertions, 24 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c
index 1dfe4b6e..175fc02e 100644
--- a/src/nxt_h1proto.c
+++ b/src/nxt_h1proto.c
@@ -45,8 +45,7 @@ static void nxt_h1p_request_body_read(nxt_task_t *task, nxt_http_request_t *r);
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_work_handler_t body_handler, void *data);
+static void nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r);
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,
@@ -1204,8 +1203,7 @@ static const nxt_str_t nxt_http_server_error[] = {
#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 999 \r\n")
static void
-nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
- nxt_work_handler_t body_handler, void *data)
+nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
{
u_char *p;
size_t size;
@@ -1291,7 +1289,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
+ && r->body_handler != NULL
&& !h1p->websocket)
{
h1p->chunked = 1;
@@ -1379,14 +1377,14 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
h1p->conn_write_tail = &header->next;
c->write_state = &nxt_h1p_request_send_state;
- if (body_handler != NULL) {
+ if (r->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, data);
+ r->body_handler, task, r, r->body_handler_data);
} else {
header->next = nxt_http_buf_last(r);
diff --git a/src/nxt_http.h b/src/nxt_http.h
index e812bd0d..d614b303 100644
--- a/src/nxt_http.h
+++ b/src/nxt_http.h
@@ -140,6 +140,9 @@ struct nxt_http_request_s {
nxt_buf_t *out;
const nxt_http_request_state_t *state;
+ nxt_work_handler_t body_handler;
+ void *body_handler_data;
+
nxt_nsec_t start_time;
nxt_str_t host;
@@ -265,8 +268,7 @@ struct nxt_http_action_s {
typedef struct {
void (*body_read)(nxt_task_t *task, nxt_http_request_t *r);
void (*local_addr)(nxt_task_t *task, nxt_http_request_t *r);
- void (*header_send)(nxt_task_t *task, nxt_http_request_t *r,
- nxt_work_handler_t body_handler, void *data);
+ void (*header_send)(nxt_task_t *task, nxt_http_request_t *r);
void (*send)(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out);
nxt_off_t (*body_bytes_sent)(nxt_task_t *task, nxt_http_proto_t proto);
void (*discard)(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *last);
@@ -326,8 +328,7 @@ nxt_http_request_t *nxt_http_request_create(nxt_task_t *task);
void nxt_http_request_error(nxt_task_t *task, nxt_http_request_t *r,
nxt_http_status_t status);
void nxt_http_request_read_body(nxt_task_t *task, nxt_http_request_t *r);
-void nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
- nxt_work_handler_t body_handler, void *data);
+void nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r);
void nxt_http_request_ws_frame_start(nxt_task_t *task, nxt_http_request_t *r,
nxt_buf_t *ws_frame);
void nxt_http_request_send(nxt_task_t *task, nxt_http_request_t *r,
diff --git a/src/nxt_http_error.c b/src/nxt_http_error.c
index 370b12db..8e9212a5 100644
--- a/src/nxt_http_error.c
+++ b/src/nxt_http_error.c
@@ -57,8 +57,8 @@ nxt_http_request_error(nxt_task_t *task, nxt_http_request_t *r,
r->state = &nxt_http_request_send_error_body_state;
- nxt_http_request_header_send(task, r,
- nxt_http_request_send_error_body, NULL);
+ r->body_handler = nxt_http_request_send_error_body;
+ nxt_http_request_header_send(task, r);
return;
fail:
diff --git a/src/nxt_http_proxy.c b/src/nxt_http_proxy.c
index 6aa3aabb..630a277a 100644
--- a/src/nxt_http_proxy.c
+++ b/src/nxt_http_proxy.c
@@ -277,7 +277,9 @@ nxt_http_proxy_header_read(nxt_task_t *task, void *obj, void *data)
r->state = &nxt_http_proxy_read_state;
- nxt_http_request_header_send(task, r, nxt_http_proxy_send_body, peer);
+ r->body_handler = nxt_http_proxy_send_body;
+ r->body_handler_data = peer;
+ nxt_http_request_header_send(task, r);
}
diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c
index e532baff..3bcf3d94 100644
--- a/src/nxt_http_request.c
+++ b/src/nxt_http_request.c
@@ -626,8 +626,7 @@ nxt_http_request_read_body(nxt_task_t *task, nxt_http_request_t *r)
void
-nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
- nxt_work_handler_t body_handler, void *data)
+nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
{
u_char *p, *end, *server_string;
nxt_int_t ret;
@@ -700,7 +699,7 @@ nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
}
if (nxt_fast_path(r->proto.any != NULL)) {
- nxt_http_proto[r->protocol].header_send(task, r, body_handler, data);
+ nxt_http_proto[r->protocol].header_send(task, r);
}
return;
diff --git a/src/nxt_http_return.c b/src/nxt_http_return.c
index b50e4ad0..f9e057b8 100644
--- a/src/nxt_http_return.c
+++ b/src/nxt_http_return.c
@@ -206,7 +206,7 @@ nxt_http_return_send_ready(nxt_task_t *task, void *obj, void *data)
r->state = &nxt_http_return_send_state;
- nxt_http_request_header_send(task, r, NULL, NULL);
+ nxt_http_request_header_send(task, r);
return;
diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c
index e51ba6b0..fc26924d 100644
--- a/src/nxt_http_static.c
+++ b/src/nxt_http_static.c
@@ -317,7 +317,6 @@ nxt_http_static_send_ready(nxt_task_t *task, void *obj, void *data)
nxt_router_conf_t *rtcf;
nxt_http_action_t *action;
nxt_http_request_t *r;
- nxt_work_handler_t body_handler;
nxt_http_static_ctx_t *ctx;
nxt_http_static_conf_t *conf;
@@ -584,11 +583,11 @@ nxt_http_static_send_ready(nxt_task_t *task, void *obj, void *data)
r->out = fb;
- body_handler = &nxt_http_static_body_handler;
+ r->body_handler = &nxt_http_static_body_handler;
} else {
nxt_file_close(task, f);
- body_handler = NULL;
+ r->body_handler = NULL;
}
} else {
@@ -646,10 +645,10 @@ nxt_http_static_send_ready(nxt_task_t *task, void *obj, void *data)
nxt_memcpy(p, r->args->start, r->args->length);
}
- body_handler = NULL;
+ r->body_handler = NULL;
}
- nxt_http_request_header_send(task, r, body_handler, NULL);
+ nxt_http_request_header_send(task, r);
r->state = &nxt_http_static_send_state;
return;
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 4e3cb303..f578303f 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -4190,7 +4190,8 @@ nxt_router_response_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg,
nxt_buf_chain_add(&r->out, b);
}
- nxt_http_request_header_send(task, r, nxt_http_request_send_body, NULL);
+ r->body_handler = nxt_http_request_send_body;
+ nxt_http_request_header_send(task, r);
if (r->websocket_handshake
&& r->status == NXT_HTTP_SWITCHING_PROTOCOLS)