Advertisement
Guest User

Untitled

a guest
Sep 11th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. # In safari:
  2. # Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
  3.  
  4. # Test in python:
  5. import requests
  6.  
  7. url = 'https://my.site.ru/api/file/'
  8. with open('test_2m', 'rb') as f:
  9.     data = {'origin': f}
  10.     r = requests.post(url, files=data)
  11.     # requests.exceptions.ConnectionError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe'))
  12.  
  13. # Test in httpie:
  14. http -f post http://my.site.ru/api/file/ origin@test_2m
  15. # http: error: ConnectionError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe'))
  16.  
  17. # Test against http://httpbin.org/post
  18. from pprint import pprint
  19. import requests
  20.  
  21. url = 'http://httpbin.org/post'
  22. with open('test_2m', 'rb') as f:
  23.     data = {'origin': f}
  24.     r = requests.post(url, files=data)
  25.     pprint(r.json()['headers'])
  26.  
  27. {'Accept': '*/*',
  28.  'Accept-Encoding': 'gzip, deflate',
  29.  'Connection': 'close',
  30.  'Content-Length': '1100145',
  31.  'Content-Type': 'multipart/form-data; '
  32.                  'boundary=216f8fc98dee4a6cbe4e295f2048bbbd',
  33.  'Host': 'httpbin.org',
  34.  'User-Agent': 'python-requests/2.14.2'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement