Skip to main content

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


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.6.tar.gz (8.5 kB view hashes)

Uploaded source

Built Distribution

http_prep-0.0.6-py3-none-any.whl (9.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page