@@ -202,6 +202,19 @@ def test_HTTP_302_REDIRECT_POST(self):
202
202
content = self .loop .run_until_complete (r .content .read ())
203
203
content = content .decode ()
204
204
205
+ self .assertEqual (r .status , 200 )
206
+ self .assertIn ('"method": "GET"' , content )
207
+ self .assertEqual (2 , httpd ['redirects' ])
208
+ r .close ()
209
+
210
+ def test_HTTP_307_REDIRECT_POST (self ):
211
+ with test_utils .run_server (self .loop , router = Functional ) as httpd :
212
+ r = self .loop .run_until_complete (
213
+ client .request ('post' , httpd .url ('redirect_307' , 2 ),
214
+ data = {'some' : 'data' }, loop = self .loop ))
215
+ content = self .loop .run_until_complete (r .content .read ())
216
+ content = content .decode ()
217
+
205
218
self .assertEqual (r .status , 200 )
206
219
self .assertIn ('"method": "POST"' , content )
207
220
self .assertEqual (2 , httpd ['redirects' ])
@@ -933,6 +946,20 @@ def redirect(self, match):
933
946
self ._start_response (302 ),
934
947
headers = {'Location' : self ._path })
935
948
949
+ @test_utils .Router .define ('/redirect_307/([0-9]+)$' )
950
+ def redirect_307 (self , match ):
951
+ no = int (match .group (1 ).upper ())
952
+ rno = self ._props ['redirects' ] = self ._props .get ('redirects' , 0 ) + 1
953
+
954
+ if rno >= no :
955
+ self ._response (
956
+ self ._start_response (307 ),
957
+ headers = {'Location' : '/method/%s' % self ._method .lower ()})
958
+ else :
959
+ self ._response (
960
+ self ._start_response (307 ),
961
+ headers = {'Location' : self ._path })
962
+
936
963
@test_utils .Router .define ('/encoding/(gzip|deflate)$' )
937
964
def encoding (self , match ):
938
965
mode = match .group (1 )
0 commit comments