Skip to content

Incorrect redirect logic #150

@dmitrypolo

Description

@dmitrypolo

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."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions