You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python version 3.6.5
Asks version 2.3.6
Trio version 0.13.0
I was using asks.Session to make async requests to a server. By accident I was using http instead of https to make the calls which was causing redirects from http --> https. Because it was a redirect the response status code was 308. The method I was using was a POST method, however it was getting overwritten by the client to be a GET.
Based on these lines only status codes 301 and 305 set the variable force_get to be False. All other 3xx error codes besides 301, 305, and 303 end up getting force_get set to be True. Because of this, on this line it overwrites the method we are sending so a POST becomes a GET. This was causing my code to fail because the GET method was not supported on that endpoint. This line should probably be modified to include 308, which states, "The request method and the body will not be altered", and 307 which states, "The method and the body of the original request are reused to perform the redirected request."
The text was updated successfully, but these errors were encountered:
I just came across the same bug. I'm migrating a code base from requests to asks and the tests are failing because of this.
I modified requests_object.py line 354 from this: if response_obj.status_code in [301, 305]:
to this: if response_obj.status_code in [301, 305, 307, 308]:
Python version 3.6.5
Asks version 2.3.6
Trio version 0.13.0
I was using
asks.Session
to makeasync
requests to a server. By accident I was usinghttp
instead ofhttps
to make the calls which was causing redirects fromhttp
-->https
. Because it was a redirect the response status code was308
. The method I was using was aPOST
method, however it was getting overwritten by the client to be aGET
.Based on these lines only status codes
301
and305
set the variableforce_get
to beFalse
. All other3xx
error codes besides301
,305
, and303
end up gettingforce_get
set to beTrue
. Because of this, on this line it overwrites the method we are sending so aPOST
becomes aGET
. This was causing my code to fail because theGET
method was not supported on that endpoint. This line should probably be modified to include 308, which states, "The request method and the body will not be altered", and 307 which states, "The method and the body of the original request are reused to perform the redirected request."The text was updated successfully, but these errors were encountered: