2019-07-11 18:37:38 +02:00
|
|
|
---
|
|
|
|
title: ''
|
|
|
|
---
|
2019-07-10 01:54:15 +02:00
|
|
|
|
2019-07-11 18:37:38 +02:00
|
|
|
http defines an HTTP client implementation
|
2019-07-10 01:54:15 +02:00
|
|
|
## Functions
|
|
|
|
|
2019-07-11 18:37:38 +02:00
|
|
|
#### def <b>delete</b>
|
|
|
|
```go
|
|
|
|
delete(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
perform an HTTP DELETE request, returning a response
|
|
|
|
|
|
|
|
**parameters:**
|
|
|
|
|
|
|
|
| name | type | description |
|
|
|
|
|------|------|-------------|
|
2019-07-11 18:37:38 +02:00
|
|
|
| '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 <b>get</b>
|
|
|
|
```go
|
|
|
|
get(url,params={},headers={},auth=()) response
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
perform an HTTP GET request, returning a response
|
|
|
|
|
|
|
|
**parameters:**
|
|
|
|
|
|
|
|
| name | type | description |
|
|
|
|
|------|------|-------------|
|
2019-07-11 18:37:38 +02:00
|
|
|
| '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 |
|
2019-07-10 01:54:15 +02:00
|
|
|
|
|
|
|
|
2019-07-11 18:37:38 +02:00
|
|
|
#### def <b>options</b>
|
|
|
|
```go
|
|
|
|
options(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
perform an HTTP OPTIONS request, returning a response
|
|
|
|
|
|
|
|
**parameters:**
|
|
|
|
|
|
|
|
| name | type | description |
|
|
|
|
|------|------|-------------|
|
2019-07-11 18:37:38 +02:00
|
|
|
| '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 <b>patch</b>
|
|
|
|
```go
|
|
|
|
patch(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
perform an HTTP PATCH request, returning a response
|
|
|
|
|
|
|
|
**parameters:**
|
|
|
|
|
|
|
|
| name | type | description |
|
|
|
|
|------|------|-------------|
|
2019-07-11 18:37:38 +02:00
|
|
|
| '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 <b>post</b>
|
|
|
|
```go
|
|
|
|
post(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
perform an HTTP POST request, returning a response
|
|
|
|
|
|
|
|
**parameters:**
|
|
|
|
|
|
|
|
| name | type | description |
|
|
|
|
|------|------|-------------|
|
2019-07-11 18:37:38 +02:00
|
|
|
| '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 <b>put</b>
|
|
|
|
```go
|
|
|
|
put(url,params={},headers={},body="",form_body={},json_body={},auth=()) response
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
perform an HTTP PUT request, returning a response
|
|
|
|
|
|
|
|
**parameters:**
|
|
|
|
|
|
|
|
| name | type | description |
|
|
|
|
|------|------|-------------|
|
2019-07-11 18:37:38 +02:00
|
|
|
| '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 |
|
2019-07-10 01:54:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-11 18:37:38 +02:00
|
|
|
## Types
|
|
|
|
### 'response'
|
2019-07-10 01:54:15 +02:00
|
|
|
the result of performing a http request
|
|
|
|
|
|
|
|
**Fields**
|
|
|
|
|
|
|
|
| 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" |
|
|
|
|
|
2019-07-11 18:37:38 +02:00
|
|
|
|
2019-07-10 01:54:15 +02:00
|
|
|
**Methods**
|
2019-07-11 18:37:38 +02:00
|
|
|
#### def <b>body</b>
|
|
|
|
```go
|
|
|
|
body() string
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
output response body as a string
|
|
|
|
|
2019-07-11 18:37:38 +02:00
|
|
|
#### def <b>json</b>
|
|
|
|
```go
|
|
|
|
json()
|
|
|
|
```
|
2019-07-10 01:54:15 +02:00
|
|
|
attempt to parse resonse body as json, returning a JSON-decoded result
|
|
|
|
|