MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / test_make

Method test_make

test/mitmproxy/test_http.py:122–149  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

120 ) # type: ignore
121
122 def test_make(self):
123 r = Request.make("GET", "https://example.com/")
124 assert r.method == "GET"
125 assert r.scheme == "https"
126 assert r.host == "example.com"
127 assert r.port == 443
128 assert r.path == "/"
129
130 r = Request.make("GET", "https://example.com/", "content", {"Foo": "bar"})
131 assert r.content == b"content"
132 assert r.headers["content-length"] == "7"
133 assert r.headers["Foo"] == "bar"
134
135 Request.make("GET", "https://example.com/", content=b"content")
136 with pytest.raises(TypeError):
137 Request.make("GET", "https://example.com/", content=42)
138
139 r = Request.make("GET", "https://example.com/", headers=[(b"foo", b"bar")])
140 assert r.headers["foo"] == "bar"
141
142 r = Request.make("GET", "https://example.com/", headers=({"foo": "baz"}))
143 assert r.headers["foo"] == "baz"
144
145 r = Request.make("GET", "https://example.com/", headers=Headers(foo="qux"))
146 assert r.headers["foo"] == "qux"
147
148 with pytest.raises(TypeError):
149 Request.make("GET", "https://example.com/", headers=42)
150
151 def test_first_line_format(self):
152 assert treq(method=b"CONNECT").first_line_format == "authority"

Callers

nothing calls this directly

Calls 2

HeadersClass · 0.90
makeMethod · 0.45

Tested by

no test coverage detected