A tool to easily create complicated and dynamic URLs and headers
Project description
A tool to easily create complicated and dynamic URLs and headers.
Install
pip install http-prep
import httpprep
URL = httpprep.URL(
protocol="https",
subdomain="www",
domain="httpbin",
top_level_domain="org",
path_segments=["post"]
)
URL.components.queries["a", "b", "b" "c", "c"] = [1, 2, ..., 4, 5]
print(URL.build(query_check=...)) # any queries whose value is equal to ... will not be included
>>> 'https://www.httpbin.org/post?a=1&b=2&c=4'
HEADERS = httpprep.Headers()
HEADERS.Accept = "*/*"
HEADERS.Authorization = "abc123"
HEADERS.Content_Disposition = ...
HEADERS["Some-Non-Standard-Header"] = 1234
print(HEADERS.format_dict(...)) # any headers whose value is equal to ... will not be included
>>> {'Accept': '*/*', 'Authorization': 'abc123', 'Some-Non-Standard-Header': 1234}
print(HEADERS.format_list(...)) # any headers whose value is equal to ... will not be included
>>> [('Accept', '*/*'), ('Authorization', 'abc123'), ('Some-Non-Standard-Header', 1234)]
print(HEADERS.format_lines(...)) # any headers whose value is equal to ... will not be included
>>> ['Accept: */*', 'Authorization: abc123', 'Some-Non-Standard-Header: 1234']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
http-prep-0.0.3.tar.gz
(8.2 kB
view hashes)
Built Distribution
Close
Hashes for http_prep-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 731ca2fca090b5358178df62358331e6ad6e4f5f011cb2b23114c90b09fb350f |
|
MD5 | 0a810c04088fe842c0c6c853ff29950c |
|
BLAKE2b-256 | 48fa8f5bbc4889a4102571421c691d02bd019816d2d4df6b4572ee6f6841a31a |