http
FetchedResponse
dataclass
¶
HttpMethod
¶
Python 3.10 does not have this enum.
https://docs.python.org/3/library/http.html#http-methods
Source code in m/core/http.py
fetch(url, headers, method=HttpMethod.get, body=None)
¶
Send an http(s) request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The url to request. |
required |
headers |
Mapping[str, str]
|
The headers for the request. By default it sets the |
required |
method |
HttpMethod
|
The request method type. Defaults to |
get
|
body |
Optional[str]
|
The body of the request. |
None
|
Returns:
Type | Description |
---|---|
OneOf[Issue, str]
|
A |
Source code in m/core/http.py
fetch_json(url, headers, method=HttpMethod.get, body_json=None)
¶
Specialized fetch to deal with json data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The url to request. |
required |
headers |
Mapping[str, str]
|
Additional headers for the request. By default it will add proper accept and content-type headers for json requests. |
required |
method |
HttpMethod
|
The request method type. Defaults to |
get
|
body_json |
Any
|
The data to send to the server (python object). |
None
|
Returns:
Type | Description |
---|---|
OneOf[Issue, Any]
|
A |
OneOf[Issue, Any]
|
Issue. |
Source code in m/core/http.py
fetch_response(url, headers, method=HttpMethod.get, body=None)
¶
Send an http(s) request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The url to request. |
required |
headers |
Mapping[str, str]
|
The headers for the request. By default it sets the |
required |
method |
HttpMethod
|
The request method type. Defaults to |
get
|
body |
Optional[str]
|
The body of the request. |
None
|
Returns:
Type | Description |
---|---|
OneOf[Issue, FetchedResponse]
|
A |