Table of Contents

http

http defines an HTTP client implementation

Functions

get

get(url,params={},headers={},auth=()) response

perform an HTTP GET request, returning a response

parameters:

nametypedescription
urlstringurl to request
headersdictoptional. dictionary of headers to add to request
authtupleoptional. (username,password) tuple for http basic authorization

put

put(url,params={},headers={},body="",form_body={},form_encoding="",json_body={},auth=()) response

perform an HTTP PUT request, returning a response

parameters:

nametypedescription
urlstringurl to request
headersdictoptional. dictionary of headers to add to request
bodystringoptional. raw string body to provide to the request
form_bodydictoptional. dict of values that will be encoded as form data
form_encodingstringoptional. application/x-www-form-url-encoded (default) or multipart/form-data
json_bodyanyoptional. json data to supply as a request. handy for working with JSON-API's
authtupleoptional. (username,password) tuple for http basic authorization

post

post(url,params={},headers={},body="",form_body={},form_encoding="",json_body={},auth=()) response

perform an HTTP POST request, returning a response

parameters:

nametypedescription
urlstringurl to request
headersdictoptional. dictionary of headers to add to request
bodystringoptional. raw string body to provide to the request
form_bodydictoptional. dict of values that will be encoded as form data
form_encodingstringoptional. application/x-www-form-url-encoded (default) or multipart/form-data
json_bodyanyoptional. json data to supply as a request. handy for working with JSON-API's
authtupleoptional. (username,password) tuple for http basic authorization

delete

delete(url,params={},headers={},body="",form_body={},form_encoding="",json_body={},auth=()) response

perform an HTTP DELETE request, returning a response

parameters:

nametypedescription
urlstringurl to request
headersdictoptional. dictionary of headers to add to request
bodystringoptional. raw string body to provide to the request
form_bodydictoptional. dict of values that will be encoded as form data
form_encodingstringoptional. application/x-www-form-url-encoded (default) or multipart/form-data
json_bodyanyoptional. json data to supply as a request. handy for working with JSON-API's
authtupleoptional. (username,password) tuple for http basic authorization

patch

patch(url,params={},headers={},body="",form_body={},form_encoding="",json_body={},auth=()) response

perform an HTTP PATCH request, returning a response

parameters:

nametypedescription
urlstringurl to request
headersdictoptional. dictionary of headers to add to request
bodystringoptional. raw string body to provide to the request
form_bodydictoptional. dict of values that will be encoded as form data
form_encodingstringoptional. application/x-www-form-url-encoded (default) or multipart/form-data
json_bodyanyoptional. json data to supply as a request. handy for working with JSON-API's
authtupleoptional. (username,password) tuple for http basic authorization

options

options(url,params={},headers={},body="",form_body={},form_encoding="",json_body={},auth=()) response

perform an HTTP OPTIONS request, returning a response

parameters:

nametypedescription
urlstringurl to request
headersdictoptional. dictionary of headers to add to request
bodystringoptional. raw string body to provide to the request
form_bodydictoptional. dict of values that will be encoded as form data
form_encodingstringoptional. application/x-www-form-url-encoded (default) or multipart/form-data
json_bodyanyoptional. json data to supply as a request. handy for working with JSON-API's
authtupleoptional. (username,password) tuple for http basic authorization

Types

response

the result of performing a http request

Fields

nametypedescription
urlstringthe url that was ultimately requested (may change after redirects)
status_codeintresponse status code (for example: 200 == OK)
headersdictdictionary of response headers
encodingstringtransfer encoding. example: "octet-stream" or "application/json"

Methods

body

body() string

output response body as a string

json

json()

attempt to parse resonse body as json, returning a JSON-decoded result