summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_h1proto.c
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@nginx.com>2023-06-29 00:30:01 +0200
committerAlejandro Colomar <alx@kernel.org>2023-10-25 13:37:50 +0200
commit9be4b16f0c99a8dd2e56fa5cd2a153ad5683c2a3 (patch)
tree318d345a3c50d2f7a37f41c75f5730800b1f3e24 /src/nxt_h1proto.c
parenta084e2bc8066ce2fed852bf04e5168e289bf834b (diff)
downloadunit-9be4b16f0c99a8dd2e56fa5cd2a153ad5683c2a3.tar.gz
unit-9be4b16f0c99a8dd2e56fa5cd2a153ad5683c2a3.tar.bz2
HTTP: refactor: storing the body_handler as part of r.
This will allow sending the header from a totally different point, since the data for the call is present in the request, which is available everywhere. It will also allow consulting in a filter if there is a body_handler installed. The gzip filter will need this, as it should be a no-op if there is no body handler installed. Signed-off-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'src/nxt_h1proto.c')
-rw-r--r--src/nxt_h1proto.c12
1 files changed, 5 insertions, 7 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);