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

Function _parse_headers_and_body

scapy/layers/http.py:258–273  ·  view source on GitHub ↗

Takes a HTTP packet, and returns a tuple containing: _ the first line (e.g., "GET ...") _ the headers in a dictionary _ the body

(s)

Source from the content-addressed store, hash-verified

256
257
258def _parse_headers_and_body(s):
259 """Takes a HTTP packet, and returns a tuple containing:
260 _ the first line (e.g., "GET ...")
261 _ the headers in a dictionary
262 _ the body
263 """
264 crlfcrlf = b"\r\n\r\n"
265 crlfcrlfIndex = s.find(crlfcrlf)
266 if crlfcrlfIndex != -1:
267 headers = s[: crlfcrlfIndex + len(crlfcrlf)]
268 body = s[crlfcrlfIndex + len(crlfcrlf) :]
269 else:
270 headers = s
271 body = b""
272 first_line, headers = headers.split(b"\r\n", 1)
273 return first_line.strip(), _parse_headers(headers), body
274
275
276def _dissect_headers(obj, s):

Callers 1

_dissect_headersFunction · 0.85

Calls 2

_parse_headersFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…