MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / parse

Method parse

lib/utils/har.py:149–179  ·  view source on GitHub ↗
(cls, raw)

Source from the content-addressed store, hash-verified

147
148 @classmethod
149 def parse(cls, raw):
150 altered = raw
151 comment = b""
152
153 if altered.startswith(b"HTTP response [") or altered.startswith(b"HTTP redirect ["):
154 stream = io.BytesIO(raw)
155 first_line = stream.readline()
156 parts = cls.extract_status.search(first_line)
157 status_line = "HTTP/1.0 %s %s" % (getText(parts.group(1)), getText(parts.group(2)))
158 remain = stream.read()
159 altered = getBytes(status_line) + b"\r\n" + remain
160 comment = first_line
161
162 response = _http_client.HTTPResponse(FakeSocket(altered))
163 response.begin()
164
165 # NOTE: https://github.com/sqlmapproject/sqlmap/issues/5942
166 response.length = len(raw[raw.find(b"\r\n\r\n") + 4:])
167
168 try:
169 content = response.read()
170 except _http_client.IncompleteRead:
171 content = raw[raw.find(b"\r\n\r\n") + 4:].rstrip(b"\r\n")
172
173 return cls(httpVersion="HTTP/1.1" if response.version == 11 else "HTTP/1.0",
174 status=response.status,
175 statusText=response.reason,
176 headers=response.msg,
177 content=content,
178 comment=comment,
179 raw=raw)
180
181 def toDict(self):
182 content = {

Callers

nothing calls this directly

Calls 8

readMethod · 0.95
getTextFunction · 0.90
getBytesFunction · 0.90
FakeSocketClass · 0.85
readlineMethod · 0.80
findMethod · 0.80
searchMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected