MCPcopy Create free account
hub / github.com/apache/trafficserver / state_send_server_request_header

Method state_send_server_request_header

src/proxy/http/HttpSM.cc:2098–2184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2096}
2097
2098int
2099HttpSM::state_send_server_request_header(int event, void *data)
2100{
2101 ink_assert(server_entry != nullptr);
2102 ink_assert(server_entry->eos == false);
2103 ink_assert(server_entry->write_vio == (VIO *)data);
2104 STATE_ENTER(&HttpSM::state_send_server_request_header, event);
2105
2106 int method;
2107
2108 switch (event) {
2109 case VC_EVENT_WRITE_READY:
2110 server_entry->write_vio->reenable();
2111 break;
2112
2113 case VC_EVENT_WRITE_COMPLETE:
2114 // We are done sending the request header, deallocate
2115 // our buffer and then decide what to do next
2116 if (server_entry->write_buffer) {
2117 free_MIOBuffer(server_entry->write_buffer);
2118 server_entry->write_buffer = nullptr;
2119 method = t_state.hdr_info.server_request.method_get_wksidx();
2120 if (!t_state.api_server_request_body_set && method != HTTP_WKSIDX_TRACE &&
2121 _ua.get_txn()->has_request_body(t_state.hdr_info.request_content_length,
2122 t_state.client_info.transfer_encoding == HttpTransact::CHUNKED_ENCODING)) {
2123 if (post_transform_info.vc) {
2124 setup_transform_to_server_transfer();
2125 } else {
2126 // Go ahead and set up the post tunnel if we are not waiting for a 100 response
2127 if (!t_state.hdr_info.client_request.m_100_continue_required) {
2128 do_setup_client_request_body_tunnel(HTTP_SERVER_VC);
2129 }
2130 }
2131 }
2132 // Any other events to these read response
2133 if (server_entry->vc_type == HTTP_SERVER_VC) {
2134 server_entry->vc_read_handler = &HttpSM::state_read_server_response_header;
2135 }
2136 }
2137
2138 break;
2139
2140 case VC_EVENT_EOS:
2141 // EOS of stream comes from the read side. Treat it as
2142 // as error if there is nothing in the read buffer. If
2143 // there is something the server may have blasted back
2144 // the response before receiving the request. Happens
2145 // often with redirects
2146 //
2147 // If we are in the middle of an api callout, it
2148 // means we haven't actually sent the request yet
2149 // so the stuff in the buffer is garbage and we
2150 // want to ignore it
2151 //
2152 server_entry->eos = true;
2153
2154 // I'm not sure about the above comment, but if EOS is received on read and we are
2155 // still in this state, we must have not gotten WRITE_COMPLETE. With epoll we might not receive EOS

Callers

nothing calls this directly

Calls 5

free_MIOBufferFunction · 0.85
method_get_wksidxMethod · 0.80
get_txnMethod · 0.80
reenableMethod · 0.45
has_request_bodyMethod · 0.45

Tested by

no test coverage detected