0

I'm trying to upload a file using httpx. This is my script:

import httpx

headers = { 'action': 'upload' }
file = 'filename.zip'
auth = httpx.DigestAuth('user', 'password')

files = {'upload-file': open('files/' + file, 'rb')}
with httpx.Client() as client:      
    r = httpx.post('http://192.168.10.10/upload', files=files, auth=auth, headers=headers)

The file is 70Mb and the script fails before the request sent the full 70MB with httpcore.WriteError: [Errno 32] Broken pipe

If I remove the auth=auth the http requests sends the full 70MB and the request completes with a 401 status.

A request such as this one is successful:

r = httpx.get('http://192.168.10.10/index.html', auth=auth)

Why would the authentication somehow lead to the upload failing?

hugo387
  • 23
  • 3
  • always put full error message (starting at word "Traceback") in question (not comment) as text (not screenshot, not link to external portal). There are other useful information. – furas Sep 18 '21 at 12:34
  • 1
    without `auth` you get status `401` so it also didn't upload it. – furas Sep 18 '21 at 12:36
  • your problem is not in httpx but in server which you have in `http://192.168.10.10`. Some servers may have limit for uploaded data and you may have to change settings in server. But all this depend on server which you have on `http://192.168.10.10`. – furas Sep 18 '21 at 12:38

0 Answers0