示例#1
0
    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
示例#2
0
    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
示例#3
0
    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
示例#4
0
    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
示例#6
0
 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 test_altsvc_frame_with_origin_serializes_properly(self):
        f = AltSvcFrame(0)
        f.host = b'google.com'
        f.port = 80
        f.protocol_id = b'h2'
        f.max_age = 29
        f.origin = Origin(scheme=b'https', host=b'yahoo.com', port=8080)

        s = f.serialize()
        assert s == self.payload_with_origin
示例#8
0
 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\"'"
     )
    def test_altsvc_frame_serialize_origin_without_port(self):
        f = AltSvcFrame(0)
        f.origin = Origin(scheme=b'https', host=b'yahoo.com', port=None)

        assert f.serialize_origin() == b'https://yahoo.com'