From 7785c96c1aea16dee0ec17403fda01b4f5ba41b3 Mon Sep 17 00:00:00 2001 From: Axel Duch Date: Wed, 24 Jul 2019 13:47:35 +0300 Subject: Added routing based on request scheme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scheme matches exact string “http” or “https”. --- src/nxt_http_request.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nxt_http_request.c') diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c index 1265c186..ce088acb 100644 --- a/src/nxt_http_request.c +++ b/src/nxt_http_request.c @@ -357,7 +357,6 @@ 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); } } -- cgit From 17bb22a4e46b390f42af665d1e92d2e1a09c9b56 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 6 Aug 2019 15:29:39 +0300 Subject: Refactored HTTP protocol callback table. --- src/nxt_http_request.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/nxt_http_request.c') diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c index ce088acb..1ab22223 100644 --- a/src/nxt_http_request.c +++ b/src/nxt_http_request.c @@ -355,8 +355,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); + if (nxt_fast_path(r->proto.any != NULL)) { + nxt_http_proto[r->protocol].local_addr(task, r); } } @@ -364,8 +364,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); } } @@ -431,8 +431,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; @@ -446,8 +446,8 @@ fail: void nxt_http_request_send(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out) { - if (r->proto.any != NULL) { - nxt_http_proto_send[r->protocol](task, r, out); + if (nxt_fast_path(r->proto.any != NULL)) { + nxt_http_proto[r->protocol].send(task, r, out); } } @@ -524,8 +524,8 @@ 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)); } } @@ -535,7 +535,7 @@ 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; @@ -556,13 +556,13 @@ nxt_http_request_close_handler(nxt_task_t *task, void *obj, void *data) } } - handler = nxt_http_proto_close[r->protocol]; + protocol = 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)) { + nxt_http_proto[protocol].close(task, proto, conf); } } -- cgit From e501c74ddceab86e48c031ca9b5e154f52dcdae0 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Tue, 20 Aug 2019 16:31:53 +0300 Subject: Introducing websocket support in router and libunit. --- src/nxt_http_request.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/nxt_http_request.c') diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c index 1ab22223..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); @@ -443,6 +441,16 @@ fail: } +void +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[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) { @@ -530,7 +538,7 @@ nxt_http_request_error_handler(nxt_task_t *task, void *obj, void *data) } -static void +void nxt_http_request_close_handler(nxt_task_t *task, void *obj, void *data) { nxt_http_proto_t proto; @@ -556,12 +564,13 @@ nxt_http_request_close_handler(nxt_task_t *task, void *obj, void *data) } } - protocol = r->protocol; - r->proto.any = NULL; - nxt_mp_release(r->mem_pool); if (nxt_fast_path(proto.any != NULL)) { + protocol = r->protocol; + + nxt_mp_release(r->mem_pool); + nxt_http_proto[protocol].close(task, proto, conf); } } -- cgit