Skip to content
Merged
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
7 changes: 4 additions & 3 deletions proxy/http/remap/RemapProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s, UrlRewrite *table)
Debug("url_rewrite", "[lookup] attempting %s lookup", proxy_request ? "proxy" : "normal");

if (table->num_rules_forward_with_recv_port) {
Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d", s->client_info.dst_addr.port());
if (table->forwardMappingWithRecvPortLookup(request_url, s->client_info.dst_addr.port(), request_host, request_host_len,
s->url_map)) {
Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d",
s->client_info.dst_addr.host_order_port());
if (table->forwardMappingWithRecvPortLookup(request_url, s->client_info.dst_addr.host_order_port(), request_host,
request_host_len, s->url_map)) {
Debug("url_rewrite", "Found forward mapping with recv port");
mapping_found = true;
} else if (table->num_rules_forward == 0) {
Expand Down
13 changes: 13 additions & 0 deletions tests/gold_tests/remap/gold/remap-https-200_3.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
``
> GET / HTTP/1.1
> Host: www.example3.com``
> User-Agent: curl/``
``
< HTTP/1.1 200 OK
< Date: ``
< Age: ``
< Transfer-Encoding: chunked
< Connection: keep-alive
< Server: ATS/``
<
``
14 changes: 14 additions & 0 deletions tests/gold_tests/remap/gold/remap2-200.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
``
> GET http://www.example2.com``
> Host: www.example2.com``
> User-Agent: curl/``
> Accept: */*
``
< HTTP/1.1 200 OK
< Date: ``
< Age: ``
< Transfer-Encoding: chunked
< Proxy-Connection: keep-alive
< Server: ATS/``
<
``
10 changes: 10 additions & 0 deletions tests/gold_tests/remap/remap_http.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
ts.Disk.remap_config.AddLine(
'map http://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port)
)
ts.Disk.remap_config.AddLine(
'map_with_recv_port http://www.example2.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.port, server.Variables.Port)
)
ts.Disk.remap_config.AddLine(
'map http://www.example.com:8080 http://127.0.0.1:{0}'.format(server.Variables.Port)
)
Expand Down Expand Up @@ -91,6 +94,13 @@
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = "gold/remap-200.gold"

# www.example2.com host (match on receive port)
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example2.com" -H "Proxy-Connection: keep-alive" --verbose'.format(
ts.Variables.port)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = "gold/remap2-200.gold"

# www.example.com:80 host
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com:80/" -H "Proxy-Connection: keep-alive" --verbose'.format(
Expand Down
10 changes: 10 additions & 0 deletions tests/gold_tests/remap/remap_https.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
ts.Disk.remap_config.AddLine(
'map https://www.example.com:{1} http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port)
)
ts.Disk.remap_config.AddLine(
'map_with_recv_port https://www.example3.com:{1} http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port)
)
ts.Disk.remap_config.AddLine(
'map https://www.anotherexample.com https://127.0.0.1:{0}'.format(server2.Variables.SSL_Port, ts.Variables.ssl_port)
)
Expand Down Expand Up @@ -99,6 +102,13 @@
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = "gold/remap-https-200.gold"

# www.example3.com (match on receive port)
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'curl --http1.1 -k https://127.0.0.1:{0} -H "Host: www.example3.com" --verbose'.format(
ts.Variables.ssl_port)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = "gold/remap-https-200_3.gold"

# no rule for this
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'curl --http1.1 -k https://127.0.0.1:{0} -H "Host: www.test.com" --verbose'.format(
Expand Down