MCPcopy Index your code
hub / github.com/secdev/scapy / HTTPRequest

Class HTTPRequest

scapy/layers/http.py:512–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510
511
512class HTTPRequest(_HTTPContent):
513 name = "HTTP Request"
514 fields_desc = (
515 [
516 # First line
517 _HTTPHeaderField("Method", "GET"),
518 _HTTPHeaderField("Path", "/"),
519 _HTTPHeaderField("Http-Version", "HTTP/1.1"),
520 # Headers
521 ]
522 + (
523 _generate_headers(
524 GENERAL_HEADERS,
525 REQUEST_HEADERS,
526 COMMON_UNSTANDARD_GENERAL_HEADERS,
527 COMMON_UNSTANDARD_REQUEST_HEADERS,
528 )
529 )
530 + [
531 _HTTPHeaderField("Unknown-Headers", None),
532 ]
533 )
534
535 def do_dissect(self, s):
536 """From the HTTP packet string, populate the scapy object"""
537 first_line, body = _dissect_headers(self, s)
538 try:
539 Method, Path, HTTPVersion = re.split(rb"\s+", first_line, maxsplit=2)
540 self.setfieldval("Method", Method)
541 self.setfieldval("Path", Path)
542 self.setfieldval("Http_Version", HTTPVersion)
543 except ValueError:
544 pass
545 if body:
546 self.raw_packet_cache = s[: -len(body)]
547 else:
548 self.raw_packet_cache = s
549 return body
550
551 def mysummary(self):
552 return self.sprintf("%HTTPRequest.Method% '%HTTPRequest.Path%' ")
553
554
555class HTTPResponse(_HTTPContent):

Callers 2

HTTP_ntlm_negotiateFunction · 0.90
requestMethod · 0.85

Calls 2

_HTTPHeaderFieldClass · 0.85
_generate_headersFunction · 0.85

Tested by

no test coverage detected