2

when uploading a big file(bigger than server limit). I expect return response with 500 status

  1. I tried postman to post API, it return 500 error, that what I need

  2. I tried requests to post API

here is requests code:

with open('invalid_big_license', 'rb') as f:
    test = s.post(
        url,
        headers=headers,
        data=None,
        files={'file': ('invalid_big_license', f)},
        timeout=1200
    )

requests raise

requests.exceptions.ConnectionError: ('Connection aborted.', OSError(41, 'Protocol wrong type for socket'))

what I need is response return with 500 status

if upload file is under server limit(like 1m), requests is success

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Rabbit.Qiu
  • 31
  • 4
  • can you provide a simpler term, like what you are trying to do, what challenge you have done, what error you are facing and what are your step, so other can replicate – sahasrara62 Dec 23 '19 at 07:38
  • What's `url`? Does it contain a scheme (`...://`)? – deceze Dec 23 '19 at 08:00
  • @deceze `url` is `http://x.x.x.x:port/api/apiname` – Rabbit.Qiu Dec 23 '19 at 08:06
  • More details are needed, but a number of servers or frameworks (like pyramid with waitress) have a specific size after which they switch to "streaming" the data when receiving large files. It might be that above a certain size your server expects a stream and therefore a different protocol? – ChatterOne Dec 23 '19 at 08:35
  • @ChatterOne could say more about this? What should I do? – Rabbit.Qiu Dec 23 '19 at 09:10
  • Turn on logging for `requests` [as per this answer](https://stackoverflow.com/a/16337639/606576) and post the output. – kthy Dec 23 '19 at 09:43

0 Answers0