Skip to content

Conversation

@montanaflynn
Copy link
Contributor

Added Python's Requests library and fixed a small bug in the node requests library as well.

Things that didn't make it in:

  • Multipart file upload could be like this:
import requests

url = "http://mockbin.com/har"

files = {'file': open('test/fixtures/files/hello.txt', 'rb')}
response = requests.request("POST", url, files=files)

print(response.text)
  • Use cookie arg like this:
import requests

url = "http://mockbin.com/har"

cookies = {'foo': 'bar', 'bar': 'baz'}

response = requests.request("GET", url, cookies=cookies)

print(response.text)
  • Use payload dict for form encoded payload like this:
import requests

url = "http://mockbin.com/har"

payload = {'foo': 'bar', 'hello': 'world'}
headers = {'content-type': 'application/x-www-form-urlencoded'}

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants