[New-bugs-announce] [issue32389] urllib3 wrong computation of 'Content-Length' for file upload

Gianguido Piani report at bugs.python.org
Wed Dec 20 13:15:40 EST 2017


New submission from Gianguido Piani <gianguido at mail.ru>:

Hi! This is my first posting ever on this site. I need to upload a simple text file to Internet servers. With "curl" the operation goes smoothly, both with http and https protocols, both up/downloads. With urllib3 and other TCP-IP handlers the generated header for 'Content-Length' contains a wrong file length indication (log verification with TCPDUMP), the file is not uploaded, the servers return different error messages.

On the contrary, urllib3 file downloads do work, also with authentication.

code example
headers = {'authorization': 'Basic ==codeduserpwd=='}
resp = http_client.request('PUT',
                           'https://webserver.com',
                           headers=headers,
                           fields={'whatfile': (filename, file_data)}
                           )

In addition, in the documentation I still haven't figured out what 'whatfile' (or any of the other keywords used there) actually is. Is this a keyword (where is the list of all allowed kwds?), the source file, the target file, or what else?? How does the function behaviour change depending on that indication?

Thankful for your support!

----------
components: Library (Lib)
messages: 308761
nosy: gianguido
priority: normal
severity: normal
status: open
title: urllib3 wrong computation of 'Content-Length' for file upload
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32389>
_______________________________________


More information about the New-bugs-announce mailing list