psf / psf/requests

POST Multipart-Encoding does not work if the Content-Type header has been previously defined in the session

Open
#6,992 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Breaking API Change
Dominant language
Python
Stars
54.3k
Forks
10.4k
Avg merge
16h 43m
Merged PRs (30d)
3

Description

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 the Content-Type header even if it has been defined at the session level
  • b. Or issue a warning message to inform the developer of their possible error

What do you think?

Best regards,
Stéphane

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example from the “POST Multiple Multipart-Encoded Files” documentation section, including a session-level Content-Type header, then trace how the session.post call prepares the multipart request. Determine the expected behavior for the conflicting header and verify it with a focused regression test or warning check; done means the behavior is documented and consistently tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.