diff options
author | Andrei Belov <defan@nginx.com> | 2019-08-22 21:33:54 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2019-08-22 21:33:54 +0300 |
commit | a07c4d30a64f781f93730576b5dced32422a9935 (patch) | |
tree | 06ebfaa66845a057b8069014c5379b2dcfc80861 /src/nxt_http_request.c | |
parent | 8a579acddeae0c0106e15d82aa7220ac01deba84 (diff) | |
parent | c47af243b0e805376c4ec908f21e07dc811b33f0 (diff) | |
download | unit-a07c4d30a64f781f93730576b5dced32422a9935.tar.gz unit-a07c4d30a64f781f93730576b5dced32422a9935.tar.bz2 |
Merged with the default branch.1.10.0-1
Diffstat (limited to 'src/nxt_http_request.c')
-rw-r--r-- | src/nxt_http_request.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c index 1265c186..916004d2 100644 --- a/src/nxt_http_request.c +++ b/src/nxt_http_request.c @@ -16,8 +16,6 @@ static void nxt_http_request_proto_info(nxt_task_t *task, static void nxt_http_request_mem_buf_completion(nxt_task_t *task, void *obj, void *data); static void nxt_http_request_done(nxt_task_t *task, void *obj, void *data); -static void nxt_http_request_close_handler(nxt_task_t *task, void *obj, - void *data); static u_char *nxt_http_date(u_char *buf, nxt_realtime_t *now, struct tm *tm, size_t size, const char *format); @@ -355,9 +353,8 @@ nxt_http_request_application(nxt_task_t *task, nxt_http_request_t *r, static void nxt_http_request_proto_info(nxt_task_t *task, nxt_http_request_t *r) { - if (r->proto.any != NULL) { - nxt_http_proto_local_addr[r->protocol](task, r); - nxt_http_proto_tls[r->protocol](task, r); + if (nxt_fast_path(r->proto.any != NULL)) { + nxt_http_proto[r->protocol].local_addr(task, r); } } @@ -365,8 +362,8 @@ nxt_http_request_proto_info(nxt_task_t *task, nxt_http_request_t *r) void nxt_http_request_read_body(nxt_task_t *task, nxt_http_request_t *r) { - if (r->proto.any != NULL) { - nxt_http_proto_body_read[r->protocol](task, r); + if (nxt_fast_path(r->proto.any != NULL)) { + nxt_http_proto[r->protocol].body_read(task, r); } } @@ -432,8 +429,8 @@ nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r) r->resp.content_length = content_length; } - if (r->proto.any != NULL) { - nxt_http_proto_header_send[r->protocol](task, r); + if (nxt_fast_path(r->proto.any != NULL)) { + nxt_http_proto[r->protocol].header_send(task, r); } return; @@ -445,10 +442,20 @@ fail: void -nxt_http_request_send(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out) +nxt_http_request_ws_frame_start(nxt_task_t *task, nxt_http_request_t *r, + nxt_buf_t *ws_frame) { if (r->proto.any != NULL) { - nxt_http_proto_send[r->protocol](task, r, out); + nxt_http_proto[r->protocol].ws_frame_start(task, r, ws_frame); + } +} + + +void +nxt_http_request_send(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out) +{ + if (nxt_fast_path(r->proto.any != NULL)) { + nxt_http_proto[r->protocol].send(task, r, out); } } @@ -525,18 +532,18 @@ nxt_http_request_error_handler(nxt_task_t *task, void *obj, void *data) r->error = 1; - if (proto.any != NULL) { - nxt_http_proto_discard[r->protocol](task, r, nxt_http_buf_last(r)); + if (nxt_fast_path(proto.any != NULL)) { + nxt_http_proto[r->protocol].discard(task, r, nxt_http_buf_last(r)); } } -static void +void nxt_http_request_close_handler(nxt_task_t *task, void *obj, void *data) { nxt_http_proto_t proto; nxt_http_request_t *r; - nxt_http_proto_close_t handler; + nxt_http_protocol_t protocol; nxt_socket_conf_joint_t *conf; nxt_router_access_log_t *access_log; @@ -557,13 +564,14 @@ nxt_http_request_close_handler(nxt_task_t *task, void *obj, void *data) } } - handler = nxt_http_proto_close[r->protocol]; - r->proto.any = NULL; - nxt_mp_release(r->mem_pool); - if (proto.any != NULL) { - handler(task, proto, conf); + if (nxt_fast_path(proto.any != NULL)) { + protocol = r->protocol; + + nxt_mp_release(r->mem_pool); + + nxt_http_proto[protocol].close(task, proto, conf); } } |