diff --git a/proxy/http/remap/RemapProcessor.cc b/proxy/http/remap/RemapProcessor.cc index 3081ae7b712..ec821488555 100644 --- a/proxy/http/remap/RemapProcessor.cc +++ b/proxy/http/remap/RemapProcessor.cc @@ -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) { diff --git a/tests/gold_tests/remap/gold/remap-https-200_3.gold b/tests/gold_tests/remap/gold/remap-https-200_3.gold new file mode 100644 index 00000000000..f5a6798af88 --- /dev/null +++ b/tests/gold_tests/remap/gold/remap-https-200_3.gold @@ -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/`` +< +`` diff --git a/tests/gold_tests/remap/gold/remap2-200.gold b/tests/gold_tests/remap/gold/remap2-200.gold new file mode 100644 index 00000000000..016e30ea804 --- /dev/null +++ b/tests/gold_tests/remap/gold/remap2-200.gold @@ -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/`` +< +`` diff --git a/tests/gold_tests/remap/remap_http.test.py b/tests/gold_tests/remap/remap_http.test.py index 551f5486644..6bf9200cf14 100644 --- a/tests/gold_tests/remap/remap_http.test.py +++ b/tests/gold_tests/remap/remap_http.test.py @@ -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) ) @@ -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( diff --git a/tests/gold_tests/remap/remap_https.test.py b/tests/gold_tests/remap/remap_https.test.py index a61d954bfb4..ba56dc88e3e 100644 --- a/tests/gold_tests/remap/remap_https.test.py +++ b/tests/gold_tests/remap/remap_https.test.py @@ -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) ) @@ -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(