Lines Matching full:downstream
113 auto downstream = in on_start_request() local
114 std::make_unique<Downstream>(this, handler_->get_mcpool(), 0); in on_start_request()
116 attach_downstream(std::move(downstream)); in on_start_request()
136 auto downstream = upstream->get_downstream(); in htp_uricb() local
137 auto &req = downstream->request(); in htp_uricb()
139 auto &balloc = downstream->get_block_allocator(); in htp_uricb()
150 assert(downstream->get_request_state() == DownstreamState::INITIAL); in htp_uricb()
151 downstream->set_request_state( in htp_uricb()
173 auto downstream = upstream->get_downstream(); in htp_hdr_keycb() local
174 auto &req = downstream->request(); in htp_hdr_keycb()
182 if (downstream->get_request_state() == DownstreamState::INITIAL) { in htp_hdr_keycb()
183 downstream->set_request_state( in htp_hdr_keycb()
189 if (downstream->get_request_state() == DownstreamState::INITIAL) { in htp_hdr_keycb()
198 downstream->set_request_state( in htp_hdr_keycb()
228 auto downstream = upstream->get_downstream(); in htp_hdr_valcb() local
229 auto &req = downstream->request(); in htp_hdr_valcb()
237 if (downstream->get_request_state() == DownstreamState::INITIAL) { in htp_hdr_valcb()
238 downstream->set_request_state( in htp_hdr_valcb()
244 if (downstream->get_request_state() == DownstreamState::INITIAL) { in htp_hdr_valcb()
339 auto downstream = upstream->get_downstream(); in htp_hdrs_completecb() local
340 auto &req = downstream->request(); in htp_hdrs_completecb()
341 auto &balloc = downstream->get_block_allocator(); in htp_hdrs_completecb()
417 downstream->inspect_http1_request(); in htp_hdrs_completecb()
420 downstream->set_chunked_request(true); in htp_hdrs_completecb()
463 downstream->set_request_state(DownstreamState::HEADER_COMPLETE); in htp_hdrs_completecb()
465 auto &resp = downstream->response(); in htp_hdrs_completecb()
477 if (mruby_ctx->run_on_request_proc(downstream) != 0) { in htp_hdrs_completecb()
491 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in htp_hdrs_completecb()
500 auto dconn = handler->get_downstream_connection(rv, downstream); in htp_hdrs_completecb()
504 upstream->redirect_to_https(downstream); in htp_hdrs_completecb()
506 downstream->set_request_state(DownstreamState::CONNECT_FAIL); in htp_hdrs_completecb()
513 if (downstream->attach_downstream_connection(std::move(dconn)) == 0) { in htp_hdrs_completecb()
523 if (dmruby_ctx->run_on_request_proc(downstream) != 0) { in htp_hdrs_completecb()
528 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in htp_hdrs_completecb()
534 rv = downstream->push_request_headers(); in htp_hdrs_completecb()
545 if (downstream->get_expect_100_continue()) { in htp_hdrs_completecb()
546 auto output = downstream->get_response_buf(); in htp_hdrs_completecb()
561 auto downstream = upstream->get_downstream(); in htp_bodycb() local
562 rv = downstream->push_upload_data_chunk( in htp_bodycb()
567 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in htp_bodycb()
586 auto downstream = upstream->get_downstream(); in htp_msg_completecb() local
587 auto &req = downstream->request(); in htp_msg_completecb()
588 auto &balloc = downstream->get_block_allocator(); in htp_msg_completecb()
594 downstream->set_request_state(DownstreamState::MSG_COMPLETE); in htp_msg_completecb()
595 rv = downstream->end_upload_data(); in htp_msg_completecb()
597 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in htp_msg_completecb()
610 downstream->get_http2_upgrade_request() && in htp_msg_completecb()
627 auto downstream = get_downstream(); in on_read() local
633 // downstream can be nullptr here, because it is initialized in the in on_read()
635 if (downstream && downstream->get_upgraded()) { in on_read()
636 auto rv = downstream->push_upload_data_chunk(rb->pos(), rb->rleft()); in on_read()
645 if (downstream->request_buf_full()) { in on_read()
647 ULOG(INFO, this) << "Downstream request buf is full"; in on_read()
657 if (downstream) { in on_read()
659 switch (downstream->get_request_state()) { in on_read()
692 // Get downstream again because it may be initialized in http parser in on_read()
694 downstream = get_downstream(); in on_read()
699 if (downstream && in on_read()
700 downstream->get_request_state() == DownstreamState::MSG_COMPLETE && in on_read()
701 downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in on_read()
714 if (downstream && in on_read()
715 downstream->get_response_state() != DownstreamState::INITIAL) { in on_read()
725 } else if (downstream) { in on_read()
726 status_code = downstream->response().http_status; in on_read()
728 if (downstream->get_request_state() == DownstreamState::CONNECT_FAIL) { in on_read()
730 } else if (downstream->get_request_state() == in on_read()
748 // downstream can be NULL here. in on_read()
749 if (downstream && downstream->request_buf_full()) { in on_read()
751 ULOG(INFO, this) << "Downstream request buffer is full"; in on_read()
763 auto downstream = get_downstream(); in on_write() local
764 if (!downstream) { in on_write()
768 auto output = downstream->get_response_buf(); in on_write()
769 const auto &resp = downstream->response(); in on_write()
777 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in on_write()
778 if (downstream->can_detach_downstream_connection()) { in on_write()
780 downstream->detach_downstream_connection(); in on_write()
783 downstream->pop_downstream_connection(); in on_write()
787 if (downstream->get_request_state() == DownstreamState::MSG_COMPLETE) { in on_write()
809 return downstream->resume_read(SHRPX_NO_BUFFER, resp.unconsumed_body_length); in on_write()
820 int HttpsUpstream::resume_read(IOCtrlReason reason, Downstream *downstream, in resume_read() argument
822 // downstream could be nullptr in resume_read()
823 if (downstream && downstream->request_buf_full()) { in resume_read()
840 auto downstream = dconn->get_downstream(); in downstream_read() local
843 rv = downstream->on_read(); in downstream_read()
846 if (downstream->get_request_header_sent()) { in downstream_read()
853 downstream->pop_downstream_connection(); in downstream_read()
858 return downstream_error(dconn, Downstream::EVENT_ERROR); in downstream_read()
861 if (downstream->get_response_state() == DownstreamState::MSG_RESET) { in downstream_read()
865 if (downstream->get_response_state() == DownstreamState::MSG_BAD_HEADER) { in downstream_read()
867 downstream->pop_downstream_connection(); in downstream_read()
871 if (downstream->can_detach_downstream_connection()) { in downstream_read()
873 downstream->detach_downstream_connection(); in downstream_read()
886 return downstream_error(dconn, Downstream::EVENT_ERROR); in downstream_write()
897 auto downstream = dconn->get_downstream(); in downstream_eof() local
903 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in downstream_eof()
907 if (downstream->get_response_state() == DownstreamState::HEADER_COMPLETE) { in downstream_eof()
913 on_downstream_body_complete(downstream); in downstream_eof()
914 downstream->set_response_state(DownstreamState::MSG_COMPLETE); in downstream_eof()
915 downstream->pop_downstream_connection(); in downstream_eof()
919 if (downstream->get_response_state() == DownstreamState::INITIAL) { in downstream_eof()
926 downstream->pop_downstream_connection(); in downstream_eof()
940 auto downstream = dconn->get_downstream(); in downstream_error() local
942 if (events & Downstream::EVENT_ERROR) { in downstream_error()
948 if (downstream->get_response_state() != DownstreamState::INITIAL) { in downstream_error()
953 if (events & Downstream::EVENT_TIMEOUT) { in downstream_error()
954 if (downstream->get_request_header_sent()) { in downstream_error()
964 downstream->pop_downstream_connection(); in downstream_error()
970 int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body, in send_reply() argument
972 const auto &req = downstream->request(); in send_reply()
973 auto &resp = downstream->response(); in send_reply()
974 auto &balloc = downstream->get_block_allocator(); in send_reply()
1002 auto output = downstream->get_response_buf(); in send_reply()
1038 downstream->response_sent_body_length += bodylen; in send_reply()
1041 downstream->set_response_state(DownstreamState::MSG_COMPLETE); in send_reply()
1047 auto downstream = get_downstream(); in error_reply() local
1049 if (!downstream) { in error_reply()
1051 std::make_unique<Downstream>(this, handler_->get_mcpool(), 1)); in error_reply()
1052 downstream = get_downstream(); in error_reply()
1055 auto &resp = downstream->response(); in error_reply()
1056 auto &balloc = downstream->get_block_allocator(); in error_reply()
1066 auto output = downstream->get_response_buf(); in error_reply()
1085 const auto &req = downstream->request(); in error_reply()
1090 downstream->response_sent_body_length += html.size(); in error_reply()
1093 downstream->set_response_state(DownstreamState::MSG_COMPLETE); in error_reply()
1096 void HttpsUpstream::attach_downstream(std::unique_ptr<Downstream> downstream) { in attach_downstream() argument
1098 downstream_ = std::move(downstream); in attach_downstream()
1109 Downstream *HttpsUpstream::get_downstream() const { return downstream_.get(); } in get_downstream()
1111 std::unique_ptr<Downstream> HttpsUpstream::pop_downstream() { in pop_downstream()
1112 return std::unique_ptr<Downstream>(downstream_.release()); in pop_downstream()
1115 int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) { in on_downstream_header_complete() argument
1117 if (downstream->get_non_final_response()) { in on_downstream_header_complete()
1118 DLOG(INFO, downstream) << "HTTP non-final response header"; in on_downstream_header_complete()
1120 DLOG(INFO, downstream) << "HTTP response header completed"; in on_downstream_header_complete()
1124 const auto &req = downstream->request(); in on_downstream_header_complete()
1125 auto &resp = downstream->response(); in on_downstream_header_complete()
1126 auto &balloc = downstream->get_block_allocator(); in on_downstream_header_complete()
1127 auto dconn = downstream->get_downstream_connection(); in on_downstream_header_complete()
1130 if (downstream->get_non_final_response() && in on_downstream_header_complete()
1131 !downstream->supports_non_final_response()) { in on_downstream_header_complete()
1137 if (!downstream->get_non_final_response()) { in on_downstream_header_complete()
1143 if (dmruby_ctx->run_on_response_proc(downstream) != 0) { in on_downstream_header_complete()
1148 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in on_downstream_header_complete()
1156 if (mruby_ctx->run_on_response_proc(downstream) != 0) { in on_downstream_header_complete()
1161 if (downstream->get_response_state() == DownstreamState::MSG_COMPLETE) { in on_downstream_header_complete()
1169 auto buf = downstream->get_response_buf(); in on_downstream_header_complete()
1175 if (req.connect_proto != ConnectProto::NONE && downstream->get_upgraded()) { in on_downstream_header_complete()
1190 downstream->rewrite_location_response_header( in on_downstream_header_complete()
1194 if (downstream->get_non_final_response()) { in on_downstream_header_complete()
1225 // We check downstream->get_response_connection_close() in case when in on_downstream_header_complete()
1232 } else if (!downstream->get_upgraded()) { in on_downstream_header_complete()
1236 if (!connect_method && downstream->get_upgraded()) { in on_downstream_header_complete()
1291 if (req.method != HTTP_CONNECT || !downstream->get_upgraded()) { in on_downstream_header_complete()
1292 auto affinity_cookie = downstream->get_affinity_cookie_to_send(); in on_downstream_header_complete()
1343 int HttpsUpstream::on_downstream_body(Downstream *downstream, in on_downstream_body() argument
1349 auto output = downstream->get_response_buf(); in on_downstream_body()
1350 if (downstream->get_chunked_response()) { in on_downstream_body()
1356 downstream->response_sent_body_length += len; in on_downstream_body()
1358 if (downstream->get_chunked_response()) { in on_downstream_body()
1364 int HttpsUpstream::on_downstream_body_complete(Downstream *downstream) { in on_downstream_body_complete() argument
1365 const auto &req = downstream->request(); in on_downstream_body_complete()
1366 auto &resp = downstream->response(); in on_downstream_body_complete()
1368 if (downstream->get_chunked_response()) { in on_downstream_body_complete()
1369 auto output = downstream->get_response_buf(); in on_downstream_body_complete()
1381 DLOG(INFO, downstream) << "HTTP response completed"; in on_downstream_body_complete()
1384 if (!downstream->validate_response_recv_body_length()) { in on_downstream_body_complete()
1390 downstream->get_request_state() != DownstreamState::MSG_COMPLETE) { in on_downstream_body_complete()
1397 int HttpsUpstream::on_downstream_abort_request(Downstream *downstream, in on_downstream_abort_request() argument
1405 Downstream *downstream) { in on_downstream_abort_request_with_https_redirect() argument
1406 redirect_to_https(downstream); in on_downstream_abort_request_with_https_redirect()
1411 int HttpsUpstream::redirect_to_https(Downstream *downstream) { in redirect_to_https() argument
1412 auto &req = downstream->request(); in redirect_to_https()
1425 auto &balloc = downstream->get_block_allocator(); in redirect_to_https()
1437 auto &resp = downstream->response(); in redirect_to_https()
1443 return send_reply(downstream, nullptr, 0); in redirect_to_https()
1463 int HttpsUpstream::on_downstream_reset(Downstream *downstream, bool no_retry) { in on_downstream_reset() argument
1467 assert(downstream == downstream_.get()); in on_downstream_reset()
1517 rv = on_downstream_abort_request_with_https_redirect(downstream); in on_downstream_reset()
1529 int HttpsUpstream::initiate_push(Downstream *downstream, const StringRef &uri) { in initiate_push() argument
1563 Downstream *
1564 HttpsUpstream::on_downstream_push_promise(Downstream *downstream, in on_downstream_push_promise() argument
1570 Downstream *downstream, Downstream *promised_downstream) { in on_downstream_push_promise_complete() argument
1577 Downstream *promised_downstream) {} in cancel_premature_downstream()