simple_httpclient follow redirect on 302 response

120 views
Skip to first unread message

bergundy

unread,
Oct 24, 2012, 6:53:07 AM10/24/12
to python-...@googlegroups.com
from [1]

      Note: Many pre-HTTP/1.1 user agents do not understand the 303
      status. When interoperability with such clients is a concern, the
      302 status code may be used instead, since most user agents react
      to a 302 response as described here for 303.

As you can see here [2], simple_httpclient switches to GET only on 303 code and not on 302.

This test reproduces the problem:
---
from tornado.testing            import AsyncHTTPTestCase
from tornado.web                import Application, RequestHandler

class TestLogin(AsyncHTTPTestCase):
    def get_app(self):
        class LoginHandler(RequestHandler):
            def post(self):
                self.redirect('/')

        class IndexHandler(RequestHandler):
            def get(self):
                self.write('ok')

        return Application([('/', IndexHandler), ('/login', LoginHandler)])

    def test_login(self):
        res = self.fetch('/login', method = 'POST', body = 'bla')
        self.assertEqual(res.code, 200)
        self.assertEqual(res.body, 'ok')
---

Should I issue a pull request for this?

Ben Darnell

unread,
Oct 28, 2012, 4:09:20 PM10/28/12
to python-...@googlegroups.com
Yeah, we should probably follow the browsers rather than the spec for
302. Feel free to file a pull request.

-Ben

Roey Berman

unread,
Oct 31, 2012, 12:57:02 PM10/31/12
to python-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages