Before you mark this as a duplicate of this question, here me out...
I am making a POST
request to http://my-local-server:80/apistuff/user' to create a user. When I walk through with a debugger, right up until the actual
requests.post()`, that URL is http.
But when I look at the Response.url
, it says https://my-local-server/apistuff/user
. Requests automatically made it an https URL. But there is a problem with this I'll explain in a moment.
The answer to the other question was to add , verify=False
as an argument to the post
call. But that only says don't verify the certificates; it still changes the URL, and more to my point, it changes THE PORT.
The app thinks it's making a call out on port 80, but it's really sent out on 443. The api does some some stuff--calls an external file with parms--which then sends the reply to the configured url. The configuration says the app is running on port 80, which is important for other sections of the code. So the api tries sending back the response from port 443 (because that's where it came from) to port 80 (because that is where it's directed to).
From this, I've gotten 308 (redirect) errors, 400 (bad request) errors, and 500 (server bad) errors depending on setup.
So verifying certs is not the problem. The problem is that it changed the url/port so it can no longer communicate back.
So the question remains: how do you send something through requests so it STAYS an http request?