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

Method tunnel_handler_post

src/proxy/http/HttpSM.cc:2766–2858  ·  view source on GitHub ↗

int HttpSM::tunnel_handler_post(int event, void* data) Handles completion of any http request body tunnel Having 'post' in its name is a misnomer

Source from the content-addressed store, hash-verified

2764// Having 'post' in its name is a misnomer
2765//
2766int
2767HttpSM::tunnel_handler_post(int event, void *data)
2768{
2769 STATE_ENTER(&HttpSM::tunnel_handler_post, event);
2770
2771 HttpTunnelProducer *p = _ua.get_txn() != nullptr ? tunnel.get_producer(_ua.get_txn()) : tunnel.get_producer(HT_HTTP_CLIENT);
2772 if (!p) {
2773 return 0; // Cannot do anything if there is no producer
2774 }
2775
2776 switch (event) {
2777 case HTTP_TUNNEL_EVENT_DONE: // Tunnel done.
2778 if (p->handler_state == HTTP_SM_POST_UA_FAIL) {
2779 // post failed
2780 switch (t_state.client_info.state) {
2781 case HttpTransact::ACTIVE_TIMEOUT:
2782 call_transact_and_set_next_state(HttpTransact::PostActiveTimeoutResponse);
2783 return 0;
2784 case HttpTransact::INACTIVE_TIMEOUT:
2785 call_transact_and_set_next_state(HttpTransact::PostInactiveTimeoutResponse);
2786 return 0;
2787 default:
2788 break;
2789 }
2790 }
2791 break;
2792 case VC_EVENT_WRITE_READY: // iocore may callback first before send.
2793 return 0;
2794 case VC_EVENT_EOS: // SSLNetVC may callback EOS during write error (6.0.x or early)
2795 case VC_EVENT_ERROR: // Send HTTP 408 error
2796 case VC_EVENT_WRITE_COMPLETE: // tunnel_handler_post_ua has sent HTTP 408 response
2797 case VC_EVENT_INACTIVITY_TIMEOUT: // _ua.get_txn() timeout during sending the HTTP 408 response
2798 case VC_EVENT_ACTIVE_TIMEOUT: // _ua.get_txn() timeout
2799 if (_ua.get_entry()->write_buffer) {
2800 free_MIOBuffer(_ua.get_entry()->write_buffer);
2801 _ua.get_entry()->write_buffer = nullptr;
2802 }
2803 if (!p->handler_state) {
2804 p->handler_state = HTTP_SM_POST_UA_FAIL;
2805 }
2806 break;
2807 case VC_EVENT_READ_READY:
2808 case VC_EVENT_READ_COMPLETE:
2809 default:
2810 ink_assert(!"not reached");
2811 return 0;
2812 }
2813
2814 ink_assert(event == HTTP_TUNNEL_EVENT_DONE);
2815 ink_assert(data == &tunnel);
2816 // The tunnel calls this when it is done
2817
2818 int p_handler_state = p->handler_state;
2819 if (is_waiting_for_full_body && !this->is_postbuf_valid()) {
2820 p_handler_state = HTTP_SM_POST_SERVER_FAIL;
2821 }
2822 if (p->vc_type != HT_BUFFER_READ) {
2823 tunnel_handler_post_or_put(p);

Callers

nothing calls this directly

Calls 6

is_postbuf_validMethod · 0.95
postbuf_buffer_availMethod · 0.95
free_MIOBufferFunction · 0.85
get_txnMethod · 0.80
get_producerMethod · 0.80
get_entryMethod · 0.80

Tested by

no test coverage detected