MCPcopy Create free account
hub / github.com/secdev/scapy / _dissect_headers

Function _dissect_headers

scapy/layers/http.py:276–293  ·  view source on GitHub ↗

Takes a HTTP packet as the string s, and populates the scapy layer obj (either HTTPResponse or HTTPRequest). Returns the first line of the HTTP packet, and the body

(obj, s)

Source from the content-addressed store, hash-verified

274
275
276def _dissect_headers(obj, s):
277 """Takes a HTTP packet as the string s, and populates the scapy layer obj
278 (either HTTPResponse or HTTPRequest). Returns the first line of the
279 HTTP packet, and the body
280 """
281 first_line, headers, body = _parse_headers_and_body(s)
282 for f in obj.fields_desc:
283 # We want to still parse wrongly capitalized fields
284 stripped_name = _strip_header_name(f.name).lower()
285 try:
286 _, value = headers.pop(stripped_name)
287 except KeyError:
288 continue
289 obj.setfieldval(f.name, value)
290 if headers:
291 headers = dict(headers.values())
292 obj.setfieldval("Unknown_Headers", headers)
293 return first_line, body
294
295
296class _HTTPContent(Packet):

Callers 4

do_dissectMethod · 0.90
do_dissectMethod · 0.90
do_dissectMethod · 0.85
do_dissectMethod · 0.85

Calls 5

_parse_headers_and_bodyFunction · 0.85
_strip_header_nameFunction · 0.85
popMethod · 0.80
setfieldvalMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…