Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4598,28 +4598,6 @@ HttpSM::do_remap_request(bool run_inline)

check_sni_host();

// Depending on a variety of factors the HOST field may or may not have been promoted to the
// client request URL. The unmapped URL should always have that promotion done. If the HOST field
// is not already there, promote it only in the unmapped_url. This avoids breaking any logic that
// depends on the lack of promotion in the client request URL.
if (!t_state.unmapped_url.m_url_impl->m_ptr_host) {
MIMEField *host_field = t_state.hdr_info.client_request.field_find(static_cast<std::string_view>(MIME_FIELD_HOST));
if (host_field) {
auto host_name{host_field->value_get()};
if (!host_name.empty()) {
int port = 0;
bool has_port = false;

if (http_parse_host_header(host_name, host_name, port, has_port)) {
t_state.unmapped_url.host_set(host_name);
}
if (has_port) {
t_state.unmapped_url.port_set(port);
}
}
}
}

if (!ret) {
SMDbg(dbg_ctl_url_rewrite, "Could not find a valid remapping entry for this request");
Metrics::Counter::increment(http_rsb.no_remap_matched);
Expand Down
3 changes: 2 additions & 1 deletion src/proxy/http/HttpTransact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,10 @@ HttpTransact::HandleBlindTunnel(State *s)
void
HttpTransact::StartRemapRequest(State *s)
{
// Preserve effective url before remap, regardless of actual need for remap
// Preserve the effective URL before remap, regardless of the actual need for remap.
s->unmapped_url.create(s->hdr_info.client_request.url_get()->m_heap);
s->unmapped_url.copy(s->hdr_info.client_request.url_get());
s->hdr_info.client_request.set_url_target_from_host_field(&s->unmapped_url);
Comment on lines 1026 to +1028

if (s->api_skip_all_remapping) {
TxnDbg(dbg_ctl_http_trans, "API request to skip remapping");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# limitations under the License.

from enum import Enum
import os
import sys

Test.Summary = 'Exercise stats-over-http plugin'
Expand Down Expand Up @@ -47,12 +48,28 @@ def __setupTS(self):
self.ts = Test.MakeATSProcess("ts")

self.ts.Disk.plugin_config.AddLine('stats_over_http.so _stats')
self.ts.Disk.logging_yaml.AddLines(
'''
logging:
formats:
- name: unmapped_url
format: "%<cquuc>"
logs:
- filename: stats_over_http_url
format: unmapped_url
'''.split("\n"))
Comment on lines +51 to +60
self.ts.Disk.File(os.path.join(self.ts.Variables.LOGDIR, 'stats_over_http_url.log'), id='unmapped_url_log')
self.ts.Disk.unmapped_url_log.Content += Testers.ContainsExpression(
rf'http://127\.0\.0\.1:{self.ts.Variables.port}/_stats', 'The unmapped URL should contain the Host header value.')
self.ts.Disk.unmapped_url_log.Content += Testers.ExcludesExpression(
'http:///', 'The unmapped URL should not omit the request host.')

self.ts.Disk.records_config.update(
{
"proxy.config.http.server_ports": f"{self.ts.Variables.port} {self.ts.Variables.uds_path}",
"proxy.config.diags.debug.enabled": 1,
"proxy.config.diags.debug.tags": "stats_over_http"
"proxy.config.diags.debug.tags": "stats_over_http",
"proxy.config.log.max_secs_per_buffer": 1,
})

def __checkProcessBefore(self, tr):
Expand Down