@@ -44,6 +44,16 @@ def get(self):
44
44
self .set_header ("Content-Length" , self .get_argument ("value" ))
45
45
self .write ("ok" )
46
46
47
+ class PRGPostHandler (RequestHandler ):
48
+ def post (self ):
49
+ self .set_header ("Location" , "/prg_get" )
50
+ self .set_status (303 )
51
+
52
+ class PRGGetHandler (RequestHandler ):
53
+ def get (self ):
54
+ self .write ("ok" )
55
+
56
+
47
57
class SimpleHTTPClientTestCase (AsyncHTTPTestCase , LogTrapTestCase ):
48
58
def get_app (self ):
49
59
# callable objects to finish pending /trigger requests
@@ -56,6 +66,8 @@ def get_app(self):
56
66
url ("/hang" , HangHandler ),
57
67
url ("/hello" , HelloWorldHandler ),
58
68
url ("/content_length" , ContentLengthHandler ),
69
+ url ("/prg_post" , PRGPostHandler ),
70
+ url ("/prg_get" , PRGGetHandler ),
59
71
], gzip = True )
60
72
61
73
def test_singleton (self ):
@@ -134,6 +146,14 @@ def test_max_redirects(self):
134
146
self .assertTrue (response .effective_url .endswith ("/countdown/2" ))
135
147
self .assertTrue (response .headers ["Location" ].endswith ("/countdown/1" ))
136
148
149
+ def test_303_redirect (self ):
150
+ response = self .fetch ("/prg_post" , method = "POST" , body = "" )
151
+ self .assertEqual (200 , response .code )
152
+ self .assertTrue (response .request .url .endswith ("/prg_post" ))
153
+ self .assertTrue (response .effective_url .endswith ("/prg_get" ))
154
+ #request is the original request, is a POST still
155
+ self .assertEqual ("POST" , response .request .method )
156
+
137
157
def test_request_timeout (self ):
138
158
response = self .fetch ('/hang' , request_timeout = 0.1 )
139
159
self .assertEqual (response .code , 599 )
0 commit comments