Lines Matching refs:r
232 static void mod_wstunnel_patch_config(request_st * const r, plugin_data * const p) { in mod_wstunnel_patch_config() argument
235 if (config_check_cond(r, (uint32_t)p->cvlist[i].k_id)) in mod_wstunnel_patch_config()
349 request_st * const r = hctx->gw.r; in wstunnel_create_env() local
351 if (0 == r->reqbody_length || r->http_version > HTTP_VERSION_1_1) { in wstunnel_create_env()
352 http_response_upgrade_read_body_unknown(r); in wstunnel_create_env()
353 chunkqueue_append_chunkqueue(&r->reqbody_queue, &r->read_queue); in wstunnel_create_env()
358 r->http_status = (r->http_version > HTTP_VERSION_1_1) in wstunnel_create_env()
361 r->resp_body_started = 1; in wstunnel_create_env()
380 request_st * const r = hctx->gw.r; in wstunnel_stdin_append() local
381 DEBUG_LOG_INFO("disconnected from client (fd=%d)", r->con->fd); in wstunnel_stdin_append()
382 DEBUG_LOG_DEBUG("send close response to client (fd=%d)", r->con->fd); in wstunnel_stdin_append()
384 gw_handle_request_reset(r, hctx->gw.plugin_data); in wstunnel_stdin_append()
389 static handler_t wstunnel_recv_parse(request_st * const r, http_response_opts * const opts, buffer … in wstunnel_recv_parse() argument
398 UNUSED(r); in wstunnel_recv_parse()
402 static int wstunnel_is_allowed_origin(request_st * const r, handler_ctx * const hctx) { in wstunnel_is_allowed_origin() argument
417 origin = http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Origin")); in wstunnel_is_allowed_origin()
420 http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Sec-WebSocket-Origin")); in wstunnel_is_allowed_origin()
425 r->http_status = 400; /* Bad Request */ in wstunnel_is_allowed_origin()
439 r->http_status = 403; /* Forbidden */ in wstunnel_is_allowed_origin()
443 static int wstunnel_check_request(request_st * const r, handler_ctx * const hctx) { in wstunnel_check_request() argument
445 http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Sec-WebSocket-Version")); in wstunnel_check_request()
451 r->http_status = 400; /* Bad Request */ in wstunnel_check_request()
456 if (!r->http_host || buffer_is_blank(r->http_host)) { in wstunnel_check_request()
458 r->http_status = 400; /* Bad Request */ in wstunnel_check_request()
462 if (!wstunnel_is_allowed_origin(r, hctx)) { in wstunnel_check_request()
481 static handler_t wstunnel_handler_setup (request_st * const r, plugin_data * const p) { in wstunnel_handler_setup() argument
482 handler_ctx *hctx = r->plugin_ctx[p->id]; in wstunnel_handler_setup()
484 hctx->errh = r->conf.errh;/*(for mod_wstunnel-specific DEBUG_* macros)*/ in wstunnel_handler_setup()
486 hybivers = wstunnel_check_request(r, hctx); in wstunnel_handler_setup()
488 r->handler_module = NULL; in wstunnel_handler_setup()
515 http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Sec-WebSocket-Protocol")); in wstunnel_handler_setup()
558 static handler_t mod_wstunnel_check_extension(request_st * const r, void *p_d) { in mod_wstunnel_check_extension() argument
562 if (NULL != r->handler_module) in mod_wstunnel_check_extension()
564 if (r->http_version > HTTP_VERSION_1_1) { in mod_wstunnel_check_extension()
565 if (!r->h2_connect_ext) in mod_wstunnel_check_extension()
569 if (r->http_method != HTTP_METHOD_GET) in mod_wstunnel_check_extension()
571 if (r->http_version != HTTP_VERSION_1_1) in mod_wstunnel_check_extension()
579 vb = http_header_request_get(r, HTTP_HEADER_UPGRADE, CONST_STR_LEN("Upgrade")); in mod_wstunnel_check_extension()
583 vb = http_header_request_get(r, HTTP_HEADER_CONNECTION, CONST_STR_LEN("Connection")); in mod_wstunnel_check_extension()
589 mod_wstunnel_patch_config(r, p); in mod_wstunnel_check_extension()
592 rc = gw_check_extension(r, (gw_plugin_data *)p, 1, sizeof(handler_ctx)); in mod_wstunnel_check_extension()
593 return (HANDLER_GO_ON == rc && r->handler_module == p->self) in mod_wstunnel_check_extension()
594 ? wstunnel_handler_setup(r, p) in mod_wstunnel_check_extension()
605 request_st * const r = &con->request; in TRIGGER_FUNC() local
606 handler_ctx *hctx = r->plugin_ctx[p->id]; in TRIGGER_FUNC()
607 if (NULL == hctx || r->handler_module != p->self) in TRIGGER_FUNC()
613 if (cur_ts - con->read_idle_ts > r->conf.max_read_idle) { in TRIGGER_FUNC()
616 gw_handle_request_reset(r, p_d); in TRIGGER_FUNC()
666 static int get_key3(request_st * const r, char *buf, uint32_t bytes) { in get_key3() argument
669 chunkqueue *cq = &r->reqbody_queue; in get_key3()
673 return chunkqueue_read_data(cq, buf, bytes, r->conf.errh); in get_key3()
697 static int create_MD5_sum(request_st * const r) { in create_MD5_sum() argument
701 http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Sec-WebSocket-Key1")); in create_MD5_sum()
703 http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Sec-WebSocket-Key2")); in create_MD5_sum()
707 get_key3(r, (char *)(buf+2), 2*sizeof(uint32_t)) < 0) { in create_MD5_sum()
724 chunkqueue_append_mem(&r->write_queue, (char *)buf, sizeof(buf)); in create_MD5_sum()
729 request_st * const r = hctx->gw.r; in create_response_ietf_00() local
733 const buffer *origin = http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Origin")); in create_response_ietf_00()
736 http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Sec-WebSocket-Origin")); in create_response_ietf_00()
742 if (!r->http_host || buffer_is_blank(r->http_host)) { in create_response_ietf_00()
748 if (create_MD5_sum(r) < 0) { in create_response_ietf_00()
753 http_header_response_set(r, HTTP_HEADER_UPGRADE, in create_response_ietf_00()
757 http_header_response_append(r, HTTP_HEADER_CONNECTION, in create_response_ietf_00()
765 http_header_response_set(r, HTTP_HEADER_OTHER, in create_response_ietf_00()
771 http_header_response_set_ptr(r, HTTP_HEADER_OTHER, in create_response_ietf_00()
773 if (buffer_is_equal_string(&r->uri.scheme, CONST_STR_LEN("https"))) in create_response_ietf_00()
777 buffer_append_str2(value, BUF_PTR_LEN(r->http_host), in create_response_ietf_00()
778 BUF_PTR_LEN(&r->uri.path)); in create_response_ietf_00()
791 request_st * const r = hctx->gw.r; in create_response_rfc_6455() local
792 if (r->http_version == HTTP_VERSION_1_1) { in create_response_rfc_6455()
797 http_header_request_get(r, HTTP_HEADER_OTHER, CONST_STR_LEN("Sec-WebSocket-Key")); in create_response_rfc_6455()
810 http_header_response_set(r, HTTP_HEADER_UPGRADE, in create_response_rfc_6455()
814 http_header_response_append(r, HTTP_HEADER_CONNECTION, in create_response_rfc_6455()
820 http_header_response_set_ptr(r, HTTP_HEADER_OTHER, in create_response_rfc_6455()
826 http_header_response_set(r, HTTP_HEADER_OTHER, in create_response_rfc_6455()
830 http_header_response_set(r, HTTP_HEADER_OTHER, in create_response_rfc_6455()
841 request_st * const r = hctx->gw.r; in mod_wstunnel_handshake_create_response() local
846 r->http_status = 400; /* Bad Request */ in mod_wstunnel_handshake_create_response()
854 if (hctx->hybivers == 0 && r->http_version == HTTP_VERSION_1_1) { in mod_wstunnel_handshake_create_response()
858 chunkqueue *cq = &r->reqbody_queue; in mod_wstunnel_handshake_create_response()
865 r->http_status = 400; /* Bad Request */ in mod_wstunnel_handshake_create_response()
873 r->http_status = 503; /* Service Unavailable */ in mod_wstunnel_handshake_create_response()
895 request_st * const r = hctx->gw.r; in send_ietf_00() local
902 http_chunk_append_mem(r, &head, 1); in send_ietf_00()
903 http_chunk_append_mem(r, payload, siz); in send_ietf_00()
904 http_chunk_append_mem(r, &tail, 1); in send_ietf_00()
909 http_chunk_append_mem(r, &head, 1); in send_ietf_00()
914 http_chunk_append_mem(r, mem, len); in send_ietf_00()
916 http_chunk_append_mem(r, &tail, 1); in send_ietf_00()
920 http_chunk_append_mem(r, &tail, 1); in send_ietf_00()
921 http_chunk_append_mem(r, &head, 1); in send_ietf_00()
929 r->con->fd, len); in send_ietf_00()
934 request_st * const r = hctx->gw.r; in recv_ietf_00() local
935 chunkqueue *cq = &r->reqbody_queue; in recv_ietf_00()
939 r->con->fd, (long long)chunkqueue_length(cq)); in recv_ietf_00()
1105 request_st * const r = hctx->gw.r; in send_rfc_6455() local
1106 http_chunk_append_mem(r, mem, len); in send_rfc_6455()
1107 if (siz) http_chunk_append_mem(r, payload, siz); in send_rfc_6455()
1109 r->con->fd, len+siz); in send_rfc_6455()
1122 request_st * const r = hctx->gw.r; in recv_rfc_6455() local
1123 chunkqueue *cq = &r->reqbody_queue; in recv_rfc_6455()
1126 r->con->fd, (long long)chunkqueue_length(cq)); in recv_rfc_6455()