Note
This module requires optional dependencies. You can install them together with pfun
using pip install pfun[http]
pfun.http.HTTP
dataclass
Module for making HTTP requests.
__init__(self, connector=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, json_serialize=<function dumps at 0x7fb19c9b3cb0>, version=HttpVersion(major=1, minor=1), cookie_jar=None, read_timeout=None, conn_timeout=None, timeout=<object object at 0x7fb1981052d0>, raise_for_status=False, connector_owner=True, auto_decompress=True, requote_redirect_url=False, trust_env=False, trace_configs=None)
special
All keyword arguments are passed to the wrapped aiohttp.ClientSession
. Refer to the originial documentation for their meaning.
make_request(self, method, url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a request using HTTP verb method
to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method |
str |
HTTP method to use. One of |
required |
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Try[ClientError, Response] |
|
pfun.http.Response
dataclass
The result of making a HTTP request.
content: bytes
dataclass-field
The response content
cookies: BaseCookie
dataclass-field
The response cookies
encoding: Union[pfun.maybe.Nothing, pfun.maybe.Just[str]]
dataclass-field
Encoding of the response content if present in the header or if detectable by chardet
headers: pfun.dict.Dict[str, str]
dataclass-field
The response headers
links: pfun.dict.Dict[str, str]
dataclass-field
The response http link header
reason: Union[pfun.maybe.Nothing, pfun.maybe.Just[str]]
dataclass-field
The reason for the request status, e.g "OK"
status: int
dataclass-field
The request status
pfun.http.HasHTTP
Module provider providing the http
module
pfun.http.get_session()
Get an effect that produces an aiohttp.ClientSession
.
Use this if you need features of aiohttp
that are not supported
by the high-level api.
Examples:
1 2 3 4 5 6 7 |
|
Returns:
Type | Description |
---|---|
Depends[HasHTTP, aiohttp.ClientSession] |
|
pfun.http.get(url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a HTTP get
request to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Effect[HasHTTP, ClientError, Response] |
|
pfun.http.put(url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a HTTP put
request to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Effect[HasHTTP, ClientError, Response] |
|
pfun.http.post(url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a HTTP post
request to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Effect[HasHTTP, ClientError, Response] |
|
pfun.http.delete(url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a HTTP delete
request to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Effect[HasHTTP, ClientError, Response] |
|
pfun.http.head(url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a HTTP head
request to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Effect[HasHTTP, ClientError, Response] |
|
pfun.http.patch(url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a HTTP patch
request to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Effect[HasHTTP, ClientError, Response] |
|
pfun.http.options(url, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, max_redirects=10, compress=None, chunked=None, expect100=False, raise_for_status=None, read_until_eof=True, proxy=None, proxy_auth=None, timeout=<object object at 0x7fb1981052d0>, ssl=None, verify_ssl=None, fingerprint=None, ssl_context=None, proxy_headers=None)
Make a HTTP options
request to URL url
. All keyword
arguments are passed to aiohttp.ClientSession.request
. Refer
to the original documentation for their meaning.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
target URL for the request |
required |
Returns:
Type | Description |
---|---|
Effect[HasHTTP, ClientError, Response] |
|