Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
converts a collection of HTTP headers into a dictionary structure for automated analysis; creates parsed and analyzed objects; accepts strings, lists, or dictionaries of header values
converts a collection of HTTP headers into a dictionary structure for automated analysis; creates parsed and analyzed objects; accepts strings, lists, or dictionaries of header values
pip install headerbreakdown
or
pip3 install headerbreakdown
or
python3 -m pip install headerbreakdown
{
"_direction": "response",
"_httpversion": "HTTP/1.1",
"_responsecode": "302",
"_responsephrase": "Found",
"location": {
"key": "Location",
"value": [
"https://www.google.com/?gws_rd=ssl"
]
},
"cachecontrol": {
"key": "Cache-Control",
"value": [
"private"
]
},
"contenttype": {
"key": "Content-Type",
"value": [
"text/html; charset=UTF-8"
],
"subvalues": [
"charset=UTF-8",
"text/html"
],
"microvalues": [
{
"microkey": "charset",
"microvalue": "UTF-8"
}
]
},
"date": {
...
from headerbreakdown import HeaderBreakdown as hb
import json
# header with multiple Host and User-Agent values
someheader = "GET /?gws_rd=ssl HTTP/1.1\r\nHost: www.google.com\r\nHost: www.bing.com\r\nHost: www.yahoo.com\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/99.0\r\nCookie: 1P_JAR=2021-03-13-04"
# create the object
h = hb(someheader)
# print only the parsed version of the header
print(h.parsed)
# print the analyzed version with subvalues, minivalues, and microkeys and microvalues
print(h.analyzed)
# print as json
print(json.dumps(h.analyzed, indent=4))
# etc
attribute | type | description |
---|---|---|
parsed | dict | main structure of parsed header information |
analyzed | dict | main structure of parsed and analyzed header information with subvalues, minivalues, and microkeys and microvalues |
_direction | string | request or response |
_method | list | request verb; length of one, unless an illegal header is present |
_host | list | request host; length of one, unless an illegal header is present |
_path | list | request path; length of one, unless an illegal header is present |
_httpversion | string | HTTP version being used |
_responsecode | string | response code number only, as a string |
_responsephrase | string | response phrase only |
_keys | list | normalized keys in the analyzed object (same as obj.keys() but omits the sub/mini/micro items) |
method
and path
are also presented as normalized keys alongside other request header keys (host
will also be present)hb_unittest.py
and commented out unit_tests()
in headerbreakdown.py_direction
if illegal headers are setFAQs
converts a collection of HTTP headers into a dictionary structure for automated analysis; creates parsed and analyzed objects; accepts strings, lists, or dictionaries of header values
We found that headerbreakdown demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.