def test_altsvc_frame_with_origin_and_stream_serializes_properly(self): # This frame is not valid, but we allow it to be serialized anyway. f = AltSvcFrame(stream_id=1) f.origin = b'example.com' f.field = b'Alt-Svc: h2=":443"; ma=2592000; persist=1' assert f.serialize() == self.payload_with_origin_and_stream
def test_altsvc_frame_with_origin_serializes_properly(self): f = AltSvcFrame(stream_id=0) f.origin = b'example.com' f.field = b'h2="alt.example.com:8000", h2=":443"' s = f.serialize() assert s == self.payload_with_origin
def build_alt_svc_frame(self, stream_id, origin, field): """ Builds a single ALTSVC frame. """ f = AltSvcFrame(stream_id) f.origin = origin f.field = field return f
def advertise_alternative_service(self, field_value): """ Advertise an RFC 7838 alternative service. The semantics of this are better documented in the ``H2Connection`` class. """ self.state_machine.process_input(StreamInputs.SEND_ALTERNATIVE_SERVICE) asf = AltSvcFrame(self.stream_id) asf.field = field_value return [asf]
def test_repr(self): f = AltSvcFrame(0) assert repr(f).endswith("origin=b'', field=b''") f.field = b'h2="alt.example.com:8000", h2=":443"' assert repr(f).endswith( "origin=b'', field=b'h2=\"alt.example.com:8000\", h2=\":443\"'") f.origin = b'example.com' assert repr(f).endswith( "origin=b'example.com', field=b'h2=\"alt.example.com:8000\", h2=\":443\"'" )