@@ -54,6 +54,16 @@ def get(self):
54
54
self .set_header ("Content-Length" , "7" )
55
55
self .set_status (204 )
56
56
57
+ class SeeOther303PostHandler (RequestHandler ):
58
+ def post (self ):
59
+ self .set_header ("Location" , "/303_get" )
60
+ self .set_status (303 )
61
+
62
+ class SeeOther303GetHandler (RequestHandler ):
63
+ def get (self ):
64
+ self .write ("ok" )
65
+
66
+
57
67
class SimpleHTTPClientTestCase (AsyncHTTPTestCase , LogTrapTestCase ):
58
68
def setUp (self ):
59
69
super (SimpleHTTPClientTestCase , self ).setUp ()
@@ -72,6 +82,8 @@ def get_app(self):
72
82
url ("/content_length" , ContentLengthHandler ),
73
83
url ("/head" , HeadHandler ),
74
84
url ("/no_content" , NoContentHandler ),
85
+ url ("/303_post" , SeeOther303PostHandler ),
86
+ url ("/303_get" , SeeOther303GetHandler ),
75
87
], gzip = True )
76
88
77
89
def test_singleton (self ):
@@ -150,6 +162,14 @@ def test_max_redirects(self):
150
162
self .assertTrue (response .effective_url .endswith ("/countdown/2" ))
151
163
self .assertTrue (response .headers ["Location" ].endswith ("/countdown/1" ))
152
164
165
+ def test_303_redirect (self ):
166
+ response = self .fetch ("/303_post" , method = "POST" , body = "" )
167
+ self .assertEqual (200 , response .code )
168
+ self .assertTrue (response .request .url .endswith ("/303_post" ))
169
+ self .assertTrue (response .effective_url .endswith ("/303_get" ))
170
+ #request is the original request, is a POST still
171
+ self .assertEqual ("POST" , response .request .method )
172
+
153
173
def test_request_timeout (self ):
154
174
response = self .fetch ('/hang' , request_timeout = 0.1 )
155
175
self .assertEqual (response .code , 599 )
0 commit comments