flattens a collection of HTTP headers into a JSON structure for automated analysis
Project description
HeaderBreakdown
flattens a collection of HTTP headers into a JSON structure for automated analysis
Installation
pip install headerbreakdown
Example Output
- this is the summary; each of these items are accessible directly as attributes; see below
Example Usage
from headerbreakdown import HeaderBreakdown
import json
# sample header with multiple Host and User-Agent values
H1 = "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 = HeaderBreakdown(H1)
# utilize attributes
print(h.output) # dictionary
print(h.json) # string
print(h.summary)
# etc
Available Attributes (all except summary included in output and json)
# main attributes (also listed below)
output (dictionary)
json (string)
nested_*
# dictionaries
output
nested_output # all objects nested under 'headers', ex. {'headers':{...}}
nested_direction_output # all objects nested under "headers"+direction, ex. {'headers':{'request':{...}}}
# lists
notices
# strings
json
nested_json # all objects nested under "headers", ex. {"headers":{...}}
nested_direction_json # all objects nested under "headers"+direction, ex. {"headers":{"request":{...}}}
direction
http_version
method
host
path
user_agent
response_code
response_phrase
summary
Releases and Updates
- 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
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
headerbreakdown-0.1.4.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for headerbreakdown-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec487a9468a32150d0a155387e474b3859f3b78eb3aa0482690b1af6c75d96e9 |
|
MD5 | 5419e5ad45dc60f37a540a138fd48a5a |
|
BLAKE2b-256 | 3b94371a116a9bdf55c41f291e4a866d400576bd05eed6fc4c6d40f06acee427 |