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

Method ModifyRequest

src/proxy/http/HttpTransact.cc:1400–1484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1398}
1399
1400void
1401HttpTransact::ModifyRequest(State *s)
1402{
1403 int scheme, hostname_len;
1404 HTTPHdr &request = s->hdr_info.client_request;
1405 static const int PORT_PADDING = 8;
1406
1407 TxnDbg(dbg_ctl_http_trans, "START HttpTransact::ModifyRequest");
1408
1409 // Initialize the state vars necessary to sending error responses
1410 bootstrap_state_variables_from_request(s, &request);
1411
1412 ////////////////////////////////////////////////
1413 // If there is no scheme, default to http //
1414 ////////////////////////////////////////////////
1415 URL *url = request.url_get();
1416
1417 s->orig_scheme = (scheme = url->scheme_get_wksidx());
1418
1419 s->method = request.method_get_wksidx();
1420 if (scheme < 0 && s->method != HTTP_WKSIDX_CONNECT) {
1421 if (s->client_info.port_attribute == HttpProxyPort::TRANSPORT_SSL) {
1422 url->scheme_set(URL_SCHEME_HTTPS, URL_LEN_HTTPS);
1423 s->orig_scheme = URL_WKSIDX_HTTPS;
1424 } else {
1425 url->scheme_set(URL_SCHEME_HTTP, URL_LEN_HTTP);
1426 s->orig_scheme = URL_WKSIDX_HTTP;
1427 }
1428 }
1429
1430 if (s->method == HTTP_WKSIDX_CONNECT && !request.is_port_in_header()) {
1431 url->port_set(80);
1432 }
1433
1434 // Ugly - this must come after the call to url->scheme_set or
1435 // it can't get the scheme properly and the wrong data is cached.
1436 // The solution should be to move the scheme detecting logic in to
1437 // the header class, rather than doing it in a random bit of
1438 // external code.
1439 const char *buf = request.host_get(&hostname_len);
1440 if (!request.is_target_in_url()) {
1441 s->hdr_info.client_req_is_server_style = true;
1442 }
1443 // Copy out buf to a hostname just in case its heap header memory is freed during coalescing
1444 // due to later HdrHeap operations
1445 char *hostname = static_cast<char *>(alloca(hostname_len + PORT_PADDING));
1446 memcpy(hostname, buf, hostname_len);
1447
1448 // Make clang analyzer happy. hostname is non-null iff request.is_target_in_url().
1449 ink_assert(hostname || s->hdr_info.client_req_is_server_style);
1450
1451 // If the incoming request is proxy-style make sure the Host: header
1452 // matches the incoming request URL. The exception is if we have
1453 // Max-Forwards set to 0 in the request
1454 int max_forwards = -1; // -1 is a valid value meaning that it didn't find the header
1455 if (request.presence(MIME_PRESENCE_MAX_FORWARDS)) {
1456 max_forwards = request.get_max_forwards();
1457 }

Callers

nothing calls this directly

Calls 15

mimefield_value_equalFunction · 0.85
url_getMethod · 0.80
scheme_get_wksidxMethod · 0.80
method_get_wksidxMethod · 0.80
scheme_setMethod · 0.80
is_port_in_headerMethod · 0.80
is_target_in_urlMethod · 0.80
presenceMethod · 0.80
get_max_forwardsMethod · 0.80
field_findMethod · 0.80
port_get_rawMethod · 0.80
field_attachMethod · 0.80

Tested by

no test coverage detected