[Python-modules-team] Bug#699844: (no subject)

Daniele Tricoli eriol at mornie.org
Tue Feb 19 04:34:27 UTC 2013


I have backported the patch, but it's not enough.

Using requests 0.12.1-2[¹]:

127.0.0.1 - - [2013-02-19 04:53:45] "POST /status/303 HTTP/1.1" 303 0 "-" "python-requests/0.12.1"
127.0.0.1 - - [2013-02-19 04:53:45] "GET /redirect/1 HTTP/1.1" 302 215 "-" "python-requests/0.12.1"
127.0.0.1 - - [2013-02-19 04:53:45] "POST /get HTTP/1.1" 405 183 "-" "python-requests/0.12.1"

I have only read the code, but I think it's because of this:
https://github.com/kennethreitz/requests/blob/v0.12.1/requests/models.py#L260

When r.status_code == 302 (I have patched this) --> method = self.method (which was POST at the 
beginning).

So we really want that strict_mode is off. I can replicate this:

  https://github.com/kennethreitz/requests/blob/v0.12.1/requests/models.py#L265

also when strict_mode is True, but IMHO duplicate this code is not a good idea: if we
want strict_mode == off, it's better we use the default behavior.

The strict_mode stuff is only used in requests/models.py:

$ grep -r strict_mode requests/
requests/defaults.py::strict_mode: If true, Requests will do its best to follow RFCs (e.g. POST 
redirects).
requests/defaults.py:defaults['strict_mode'] = False
requests/models.py:                # Do what the browsers do if strict_mode is off...
requests/models.py:                if (not self.config.get('strict_mode')):

Last release doesn't use this strict_mode stuff:
https://github.com/kennethreitz/requests/blob/v1.1.0/requests/sessions.py#L111

What do you suggest?

Kind regards,

[¹] http://anonscm.debian.org/viewvc/python-modules/packages/requests/branches/0.12.1/

-- 
 Daniele Tricoli 'Eriol'
 http://mornie.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.alioth.debian.org/pipermail/python-modules-team/attachments/20130219/ee0f4fec/attachment.pgp>


More information about the Python-modules-team mailing list