You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/08/30 18:16:37 UTC
[trafficserver] branch master updated: Follows 308 Permanent
Redirect
This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 6e1e8c2 Follows 308 Permanent Redirect
6e1e8c2 is described below
commit 6e1e8c2dc8af72e7114b590378b92a336794c111
Author: Derek Dagit <de...@oath.com>
AuthorDate: Mon Aug 20 22:18:25 2018 -0500
Follows 308 Permanent Redirect
---
proxy/http/HttpSM.cc | 1 +
proxy/http/HttpTransact.cc | 1 +
tests/gold_tests/redirect/redirect.test.py | 39 ++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index fee0594..fc6b65a 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -7952,6 +7952,7 @@ HttpSM::is_redirect_required()
case HTTP_STATUS_SEE_OTHER: // 303
case HTTP_STATUS_USE_PROXY: // 305
case HTTP_STATUS_TEMPORARY_REDIRECT: // 307
+ case HTTP_STATUS_PERMANENT_REDIRECT: // 308
redirect_required = true;
break;
default:
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 78d24eb..689a64f 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -3784,6 +3784,7 @@ HttpTransact::handle_forward_server_connection_open(State *s)
case HTTP_STATUS_SEE_OTHER: // 303
case HTTP_STATUS_USE_PROXY: // 305
case HTTP_STATUS_TEMPORARY_REDIRECT: // 307
+ case HTTP_STATUS_PERMANENT_REDIRECT: // 308
break;
default:
TxnDebug("http_trans", "[hfsco] redirect in progress, non-3xx response, setting cache_do_write");
diff --git a/tests/gold_tests/redirect/redirect.test.py b/tests/gold_tests/redirect/redirect.test.py
index f6fb755..330f546 100644
--- a/tests/gold_tests/redirect/redirect.test.py
+++ b/tests/gold_tests/redirect/redirect.test.py
@@ -108,4 +108,43 @@ tr.StillRunningAfter = dns
tr.Processes.Default.Streams.stdout = "gold/redirect.gold"
tr.Processes.Default.ReturnCode = 0
+
+for status,phrase in sorted({
+ 301:'Moved Permanently',
+ 302:'Found',
+ 303:'See Other',
+ 305:'Use Proxy',
+ 307:'Temporary Redirect',
+ 308:'Permanent Redirect',
+ }.items()):
+
+ redirect_request_header = {
+ "headers": ("GET /redirect{0} HTTP/1.1\r\n"
+ "Host: *\r\n\r\n").\
+ format(status),
+ "timestamp": "5678",
+ "body": ""}
+ redirect_response_header = {
+ "headers": ("HTTP/1.1 {0} {1}\r\n"
+ "Connection: close\r\n"
+ "Location: /redirect\r\n\r\n").\
+ format(status, phrase),
+ "timestamp": "5678",
+ "body": ""}
+ redirect_serv.addResponse("sessionfile.log", redirect_request_header, redirect_response_header)
+
+ tr = Test.AddTestRun("FollowsRedirect{0}".format(status))
+ with open(os.path.join(data_path, tr.Name), 'w') as f:
+ f.write(('GET /redirect{0} HTTP/1.1\r\n'
+ 'Host: iwillredirect.test:{1}\r\n\r\n').\
+ format(status, redirect_serv.Variables.Port))
+ tr.Processes.Default.Command = "python tcp_client.py 127.0.0.1 {0} {1} | egrep -v '^(Date: |Server: ATS/)'".\
+ format(ts.Variables.port, os.path.join(data_dirname, tr.Name))
+ tr.StillRunningAfter = ts
+ tr.StillRunningAfter = redirect_serv
+ tr.StillRunningAfter = dest_serv
+ tr.StillRunningAfter = dns
+ tr.Processes.Default.Streams.stdout = "gold/redirect.gold"
+ tr.Processes.Default.ReturnCode = 0
+
Test.Setup.Copy(data_path)