MCPcopy Create free account
hub / github.com/apache/httpd / parse_response

Method parse_response

test/modules/proxy/test_02_unix.py:163–193  ·  view source on GitHub ↗
(self, lines)

Source from the content-addressed store, hash-verified

161 )
162
163 def parse_response(self, lines) -> ExecResult:
164 exp_body = False
165 exp_stat = True
166 r = ExecResult(args=[], exit_code=0, stdout=b'', stderr=b'')
167 header = {}
168 body = []
169 for line in lines:
170 if exp_stat:
171 m = re.match(r'^(\S+) (\d+) (.*)$', line)
172 assert m, f"first line no HTTP status line: {line}"
173 r.add_response({
174 "protocol": m.group(1),
175 "status": int(m.group(2)),
176 "description": m.group(3),
177 "body": r.outraw
178 })
179 header = {}
180 exp_stat = False
181 exp_body = False
182 elif re.match(r'^\r?$', line):
183 exp_body = True
184 elif exp_body:
185 body.append(line)
186 else:
187 m = re.match(r'^([^:]+):\s*(.*)$', line)
188 assert m, f"not a header line: {line}"
189 header[m.group(1).lower()] = m.group(2)
190 if r.response:
191 r.response["header"] = header
192 r.response["body"] = body
193 return r

Callers 1

test_proxy_02_003Method · 0.95

Calls 2

add_responseMethod · 0.95
ExecResultClass · 0.90

Tested by

no test coverage detected