mirror of
https://github.com/mcuadros/ascode
synced 2024-11-26 06:01:08 +01:00
5.5 KiB
5.5 KiB
title |
---|
http defines an HTTP client implementation
Index
- def delete(url,params={},headers={},body="",form_body={},json_body={},auth=
- def get(url,params={},headers={},auth=
- def options(url,params={},headers={},body="",form_body={},json_body={},auth=
- def patch(url,params={},headers={},body="",form_body={},json_body={},auth=
- def post(url,params={},headers={},body="",form_body={},json_body={},auth=
- def put(url,params={},headers={},body="",form_body={},json_body={},auth=
- type response
Functions
def http.delete
http.delete(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
perform an HTTP DELETE request, returning a response
Arguments
name | type | description |
---|---|---|
url |
string |
url to request |
headers |
dict |
optional. dictionary of headers to add to request |
body |
string |
optional. raw string body to provide to the request |
form_body |
dict |
optional. dict of values that will be encoded as form data |
json_body |
any |
optional. json data to supply as a request. handy for working with JSON-API's |
auth |
tuple |
optional. (username,password) tuple for http basic authorization |
def http.get
http.get(url,params={},headers={},auth=()) response
perform an HTTP GET request, returning a response
Arguments
name | type | description |
---|---|---|
url |
string |
url to request |
headers |
dict |
optional. dictionary of headers to add to request |
auth |
tuple |
optional. (username,password) tuple for http basic authorization |
def http.options
http.options(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
perform an HTTP OPTIONS request, returning a response
Arguments
name | type | description |
---|---|---|
url |
string |
url to request |
headers |
dict |
optional. dictionary of headers to add to request |
body |
string |
optional. raw string body to provide to the request |
form_body |
dict |
optional. dict of values that will be encoded as form data |
json_body |
any |
optional. json data to supply as a request. handy for working with JSON-API's |
auth |
tuple |
optional. (username,password) tuple for http basic authorization |
def http.patch
http.patch(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
perform an HTTP PATCH request, returning a response
Arguments
name | type | description |
---|---|---|
url |
string |
url to request |
headers |
dict |
optional. dictionary of headers to add to request |
body |
string |
optional. raw string body to provide to the request |
form_body |
dict |
optional. dict of values that will be encoded as form data |
json_body |
any |
optional. json data to supply as a request. handy for working with JSON-API's |
auth |
tuple |
optional. (username,password) tuple for http basic authorization |
def http.post
http.post(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
perform an HTTP POST request, returning a response
Arguments
name | type | description |
---|---|---|
url |
string |
url to request |
headers |
dict |
optional. dictionary of headers to add to request |
body |
string |
optional. raw string body to provide to the request |
form_body |
dict |
optional. dict of values that will be encoded as form data |
json_body |
any |
optional. json data to supply as a request. handy for working with JSON-API's |
auth |
tuple |
optional. (username,password) tuple for http basic authorization |
def http.put
http.put(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
perform an HTTP PUT request, returning a response
Arguments
name | type | description |
---|---|---|
url |
string |
url to request |
headers |
dict |
optional. dictionary of headers to add to request |
body |
string |
optional. raw string body to provide to the request |
form_body |
dict |
optional. dict of values that will be encoded as form data |
json_body |
any |
optional. json data to supply as a request. handy for working with JSON-API's |
auth |
tuple |
optional. (username,password) tuple for http basic authorization |
Types
type response
the result of performing a http request
Properties
name | type | description |
---|---|---|
url |
string |
the url that was ultimately requested (may change after redirects) |
status_code |
int |
response status code (for example: 200 == OK) |
headers |
dict |
dictionary of response headers |
encoding |
string |
transfer encoding. example: "octet-stream" or "application/json" |
Methods
def response.body
response.body() string
output response body as a string
def response.json
response.json()
attempt to parse resonse body as json, returning a JSON-decoded result