HeaderBreakdown
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
Installation
pip install headerbreakdown
or
pip3 install headerbreakdown
or
python3 -m pip install headerbreakdown
Example Output
{
"_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": {
...
Example Usage
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
Available Attributes
| 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) |
- Note that
methodandpathare also presented as normalized keys alongside other request header keys (hostwill also be present)
Releases and Updates
- 2022-08-11
- minor edits and comments for readability
- made
hb_unittest.pyand commented outunit_tests()in headerbreakdown.py
- 2022-08-10
- converted method and path to lists to accomodate illegal headers such as multiple methods and paths
- fixed attributes to only set if not already present
- prevents "requestrequest" or "responseresponse" for
_directionif illegal headers are set
- prevents "requestrequest" or "responseresponse" for
- 2022-03-25
- complete overhaul
- accepts strings, lists, and dictionaries as input
- simplified output dict structure
- standardized keys
- removed json outputs
- TO DO - convert metadata string attributes to lists (smuggling)
- 2021-04-06
- added nested_direction_json/output, ex. {"headers":{"request":{...}}}
- so direction gets captured and headers do not get overwritten if processing a capture with both sides of the communication
- the nested_direction_* attributes will be type None when processing a single, direction-ambiguous header (ex. "Set-Cookie: k1=v1;k2=v2")
- 2021-04-01
- minor fix for HTTP/ detection
- 2021-03-23
- minor edits, added summary and nested_output/nested_json attributes, ex. {"headers":{...}}
- 2021-03-13
- first release
Metadata
Release files for headerbreakdown 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| headerbreakdown-0.1.5.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| headerbreakdown-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / headerbreakdown-0.1.5.tar.gz
| Download URL | headerbreakdown-0.1.5.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78d81cbe3d8dd580bbf04de7996bbb4f1b9842f58b04b61e972437154e9723a1
|
|
BLAKE2b-256 checksum How to use checksums |
46ca75b469416b4bce338ab6e52b16679bebbe22a199dc69ebe297676144dd4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.9
|
Release files / headerbreakdown-0.1.5-py3-none-any.whl
| Download URL | headerbreakdown-0.1.5-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c9a50083c4ae3922356a241a5a64d3d1083a8adf4fcbe93c37bc2820a2b0b76
|
|
BLAKE2b-256 checksum How to use checksums |
1c7779e5151250f641e5be075e3981099923d7b2ba39e314ff238a1a9f521116
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.9
|