Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should be closed when post a file #5061

Open
chibuchifan opened this issue Apr 18, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@chibuchifan
Copy link

commented Apr 18, 2019

the post-a-multipart-encoded-file demo show:

>>> url = 'https://httpbin.org/post'
>>> files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})}

>>> r = requests.post(url, files=files)
>>> r.text
{
  ...
  "files": {
    "file": "<censored...binary...data>"
  },
  ...
}

here open a file report.xls, and in requests.module.RequestEncodingMixin it read the opened file:

            if isinstance(fp, (str, bytes, bytearray)):
                fdata = fp
            elif hasattr(fp, 'read'):
               # todo **here**
                fdata = fp.read()
            elif fp is None:
                continue
            else:
                fdata = fp

so i'm not sure if it should be close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.