mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-31 07:18:58 +00:00
http2: implement error response
This commit is contained in:
parent
a0d8afd0fc
commit
ec68aa303e
@ -179,7 +179,7 @@ class Response(message.Message):
|
|||||||
|
|
||||||
body = self.body
|
body = self.body
|
||||||
if body:
|
if body:
|
||||||
body = body.values(settings)
|
body = body.string()
|
||||||
|
|
||||||
self.rendered_values = settings.protocol.create_response(
|
self.rendered_values = settings.protocol.create_response(
|
||||||
self.code.string(),
|
self.code.string(),
|
||||||
@ -192,17 +192,11 @@ class Response(message.Message):
|
|||||||
return ":".join([i.spec() for i in self.tokens])
|
return ":".join([i.spec() for i in self.tokens])
|
||||||
|
|
||||||
def make_error_response(reason, body=None):
|
def make_error_response(reason, body=None):
|
||||||
raise NotImplementedError
|
tokens = [
|
||||||
# tokens = [
|
Code("800"),
|
||||||
# Code("800"),
|
Body(base.TokValueLiteral("pathod error: " + (body or reason))),
|
||||||
# Header(
|
]
|
||||||
# base.TokValueLiteral("Content-Type"),
|
return Response(tokens)
|
||||||
# base.TokValueLiteral("text/plain")
|
|
||||||
# ),
|
|
||||||
# Reason(base.TokValueLiteral(reason)),
|
|
||||||
# Body(base.TokValueLiteral("pathod error: " + (body or reason))),
|
|
||||||
# ]
|
|
||||||
# return Response(tokens)
|
|
||||||
|
|
||||||
# class Frame(message.Message):
|
# class Frame(message.Message):
|
||||||
# pass
|
# pass
|
||||||
|
@ -306,8 +306,11 @@ class PathodHandler(tcp.BaseHandler):
|
|||||||
)])
|
)])
|
||||||
else:
|
else:
|
||||||
if self.use_http2:
|
if self.use_http2:
|
||||||
raise NotImplementedError(\
|
anchor_gen = iter([self.make_http_error_response(
|
||||||
"HTTP/2 only supports request/response with the craft anchor point.")
|
"Spec Error",
|
||||||
|
"HTTP/2 only supports request/response with the craft anchor point: %s" %
|
||||||
|
self.server.craftanchor
|
||||||
|
)])
|
||||||
|
|
||||||
|
|
||||||
if anchor_gen:
|
if anchor_gen:
|
||||||
|
Loading…
Reference in New Issue
Block a user