Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add Python Requests library#46

Merged
ahmadnassri merged 1 commit intoKong:masterKong/httpsnippet:masterfrom
montanaflynn:mastermontanaflynn/httpsnippet:masterCopy head branch name to clipboard
Mar 19, 2015
Merged

Add Python Requests library#46
ahmadnassri merged 1 commit intoKong:masterKong/httpsnippet:masterfrom
montanaflynn:mastermontanaflynn/httpsnippet:masterCopy head branch name to clipboard

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.