POST Multipart-Encoding does not work if the Content-Type header has been previously defined in the session
Hi,
I just wasted two hours because it seems that the POST Multiple Multipart-Encoded Files function does not work if a Content-Type has been previously defined at the session level.
Example:
...
session.headers.update({“Content-Type”: “application/json”})
...
response = session.post(
“http://localhost:3000/api/v1/pipelines/upload”,
files={
“file”: (“hello_world3.py”, f, “text/x-python”)
},
data={
“urlIdx”: “2”
}
)
Two suggestions:
a.Either modify the implementation of POST Multiple Multipart-Encoded Files to overwrite the content of theContent-Typeheader even if it has been defined at the session levelb.Or issue a warning message to inform the developer of their possible error
What do you think?
Best regards, Stéphane
Folks ignore warnings or complain about them because "They meant to do that". We used to have docs that warned against what you're doing explicitly as well as setting things like the "Host" header. I don't know when those documentation warnings were removed (or if sphinx just isn't finding them in the search) but that's the best you're going to get.
This behaviour has been the standard for the library since 0.x and is one of the few things that didn't break in 1.x or 2.x.
Hi maintainers,
I'd like to work on this issue and propose a solution. Could you please assign this task to me?
Thank you!