Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests # From package 'python-requests-2.12.4-1' in Debian stretch
- def makeGenerator():
- yield 'Some data'
- headers = {
- 'Host': 'www.example.com',
- }
- response = requests.post('http://127.0.0.1:3000', data=makeGenerator(), headers=headers)
- print(response)
- # Produced output: (get it by running 'nc --vvlp 3000')
- # listening on [any] 3000 ...
- # connect to [127.0.0.1] from localhost [127.0.0.1] 36412
- # POST / HTTP/1.1
- # Host: 127.0.0.1:3000
- # Connection: keep-alive
- # Accept-Encoding: gzip, deflate
- # Accept: */*
- # User-Agent: python-requests/2.12.4
- # Host: www.example.com
- # Transfer-Encoding: chunked
- #
- # 9
- # Some data
- # 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement