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)
| 274 | |
| 275 | |
| 276 | def _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 | |
| 296 | class _HTTPContent(Packet): |
no test coverage detected
searching dependent graphs…