import h11
conn = h11.Connection(our_role=h11.CLIENT)
conn.send(h11.Request(method='GET', target='/', headers=[('Host', 'foo')]))
conn.send(h11.EndOfMessage())
conn.receive_data(b'')
try:
conn.next_event()
except h11.RemoteProtocolError as exc:
print(exc.error_status_hint)
This prints:
The error_status_hint might make sense when our_role=h11.CLIENT insofar as a server may be acting as a gateway. In that case, it may be more useful to have this hint set to 502 (Bad Gateway). Or perhaps removed altogether, so that (presumably) the server’s default 5xx kicks in — but this would be a breaking API change.
This prints:
The
error_status_hintmight make sense whenour_role=h11.CLIENTinsofar as a server may be acting as a gateway. In that case, it may be more useful to have this hint set to 502 (Bad Gateway). Or perhaps removed altogether, so that (presumably) the server’s default 5xx kicks in — but this would be a breaking API change.