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

Function how_to_open_connection

src/proxy/http/HttpTransact.cc:798–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796}
797
798inline static HttpTransact::StateMachineAction_t
799how_to_open_connection(HttpTransact::State *s)
800{
801 ink_assert((s->pending_work == nullptr) || (s->current.request_to == ResolveInfo::PARENT_PROXY));
802
803 // Originally we returned which type of server to open
804 // Now, however, we may want to issue a cache
805 // operation first in order to lock the cache
806 // entry to prevent multiple origin server requests
807 // for the same document.
808 // The cache operation that we actually issue, of
809 // course, depends on the specified "cache_action".
810 // If there is no cache-action to be issued, just
811 // connect to the server.
812 switch (s->cache_info.action) {
813 case HttpTransact::CACHE_PREPARE_TO_DELETE:
814 case HttpTransact::CACHE_PREPARE_TO_UPDATE:
815 case HttpTransact::CACHE_PREPARE_TO_WRITE:
816 s->transact_return_point = HttpTransact::handle_cache_write_lock;
817 return HttpTransact::SM_ACTION_CACHE_ISSUE_WRITE;
818 default:
819 // This covers:
820 // CACHE_DO_UNDEFINED, CACHE_DO_NO_ACTION, CACHE_DO_DELETE,
821 // CACHE_DO_LOOKUP, CACHE_DO_REPLACE, CACHE_DO_SERVE,
822 // CACHE_DO_SERVE_AND_DELETE, CACHE_DO_SERVE_AND_UPDATE,
823 // CACHE_DO_UPDATE, CACHE_DO_WRITE, TOTAL_CACHE_ACTION_TYPES
824 break;
825 }
826
827 HttpTransact::StateMachineAction_t connect_next_action = HttpTransact::SM_ACTION_ORIGIN_SERVER_OPEN;
828
829 // Setting up a direct CONNECT tunnel enters OriginServerRawOpen. We always do that if we
830 // are not forwarding CONNECT and are not going to a parent proxy.
831 if (s->method == HTTP_WKSIDX_CONNECT) {
832 if (s->txn_conf->forward_connect_method != 1 && s->parent_result.result != PARENT_SPECIFIED) {
833 connect_next_action = HttpTransact::SM_ACTION_ORIGIN_SERVER_RAW_OPEN;
834 }
835 }
836
837 if (!s->already_downgraded) { // false unless downgraded previously (possibly due to HTTP 505)
838 (&s->hdr_info.server_request)->version_set(HTTP_1_1);
839 HttpTransactHeaders::convert_request(s->current.server->http_version, &s->hdr_info.server_request);
840 }
841
842 return connect_next_action;
843}
844
845/*****************************************************************************
846 *****************************************************************************

Calls 1

version_setMethod · 0.80

Tested by

no test coverage detected