Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import requests  # From package 'python-requests-2.12.4-1' in Debian stretch
  2.  
  3. def makeGenerator():
  4.     yield 'Some data'
  5.  
  6. headers = {
  7.     'Host': 'www.example.com',
  8. }
  9.  
  10. response = requests.post('http://127.0.0.1:3000', data=makeGenerator(), headers=headers)
  11. print(response)
  12.  
  13. # Produced output: (get it by running 'nc --vvlp 3000')
  14.  
  15. # listening on [any] 3000 ...
  16. # connect to [127.0.0.1] from localhost [127.0.0.1] 36412
  17. # POST / HTTP/1.1
  18. # Host: 127.0.0.1:3000
  19. # Connection: keep-alive
  20. # Accept-Encoding: gzip, deflate
  21. # Accept: */*
  22. # User-Agent: python-requests/2.12.4
  23. # Host: www.example.com
  24. # Transfer-Encoding: chunked
  25. #
  26. # 9
  27. # Some data
  28. # 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement