Skip to content

Commit

Permalink
Upgrade h11 to 0.6.0-dev.
Browse files Browse the repository at this point in the history
Since the reason support of h11 is still in master branch,
we need to install h11 from github.
  • Loading branch information
mike820324 committed Oct 27, 2016
1 parent a93dcde commit 77d2d91
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions microproxy/protocol/http1.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def send_request(self, request):
method=request.method,
target=request.path,
headers=request.headers,
keep_case=True))
))
if request.body:
self.send(h11.Data(data=request.body))
self.send(h11.EndOfMessage())
Expand All @@ -136,7 +136,7 @@ def send_response(self, response):
status_code=int(response.code),
reason=response.reason,
headers=response.headers,
keep_case=True))
))
if response.body:
self.send(h11.Data(data=response.body))
self.send(h11.EndOfMessage())
Expand All @@ -149,7 +149,7 @@ def send_info_response(self, response):
status_code=int(response.code),
headers=response.headers,
reason=response.reason,
keep_case=True))
))

def _default_on_unhandled(self, *args): # pragma: no cover
logger.warn("unhandled event: {0}".format(args))
Expand Down
6 changes: 3 additions & 3 deletions microproxy/test/event/test_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_http1(self):
self.assertEqual(req.version, "HTTP/1.1")
self.assertEqual(req.path, "/")
self.assertEqual(req.headers, HttpHeaders([
("Host", "localhost")]))
("host", "localhost")]))

@gen_test
def test_http1_post_body(self):
Expand Down Expand Up @@ -100,8 +100,8 @@ def test_http1_post_body(self):
self.assertEqual(req.version, "HTTP/1.1")
self.assertEqual(req.path, "/")
self.assertEqual(req.headers, HttpHeaders([
("Host", "localhost"),
("Content-Length", str(body_length))]))
("host", "localhost"),
("content-length", str(body_length))]))
self.assertEqual(req.body, body)

@gen_test
Expand Down
16 changes: 8 additions & 8 deletions microproxy/test/layer/test_http1.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_req_and_resp(self):
self.assertEqual(request.method, "GET")
self.assertEqual(request.version, "HTTP/1.1")
self.assertEqual(request.path, "/index")
self.assertEqual(request.headers, HttpHeaders([("Host", "localhost")]))
self.assertEqual(request.headers, HttpHeaders([("host", "localhost")]))

self.server_conn.send_response(HttpResponse(
version="HTTP/1.1", code="200", reason="OK",
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_write_resp_to_src_failed(self):
self.assertEqual(request.method, "GET")
self.assertEqual(request.version, "HTTP/1.1")
self.assertEqual(request.path, "/index")
self.assertEqual(request.headers, HttpHeaders([("Host", "localhost")]))
self.assertEqual(request.headers, HttpHeaders([("host", "localhost")]))

self.client_stream.close()

Expand All @@ -168,7 +168,7 @@ def test_replay(self):
self.assertEqual(request.method, "GET")
self.assertEqual(request.version, "HTTP/1.1")
self.assertEqual(request.path, "/index")
self.assertEqual(request.headers, HttpHeaders([("Host", "localhost")]))
self.assertEqual(request.headers, HttpHeaders([("host", "localhost")]))

self.server_conn.send_response(HttpResponse(
version="HTTP/1.1", code="200", reason="OK",
Expand Down Expand Up @@ -208,8 +208,8 @@ def test_on_websocket(self):
self.assertEqual(request.version, "HTTP/1.1")
self.assertEqual(request.path, "/chat")
self.assertEqual(request.headers,
HttpHeaders([("Host", "localhost"),
("Upgrade", "websocket")]))
HttpHeaders([("host", "localhost"),
("upgrade", "websocket")]))

self.server_conn.send_info_response(HttpResponse(
version="HTTP/1.1", code="101", reason="Switching Protocol",
Expand All @@ -224,7 +224,7 @@ def test_on_websocket(self):
self.assertEqual(response.reason, "Switching Protocol")
self.assertEqual(
response.headers,
HttpHeaders([("Upgrade", "websocket"), ("Connection", "Upgrade")]))
HttpHeaders([("upgrade", "websocket"), ("connection", "Upgrade")]))

self.assertTrue(http_layer_future.done())
yield http_layer_future
Expand All @@ -245,7 +245,7 @@ def test_read_response_without_chunked_and_content_length(self):
self.assertEqual(request.method, "GET")
self.assertEqual(request.version, "HTTP/1.1")
self.assertEqual(request.path, "/index")
self.assertEqual(request.headers, HttpHeaders([("Host", "localhost")]))
self.assertEqual(request.headers, HttpHeaders([("host", "localhost")]))

yield self.server_stream.write(
(b"HTTP/1.1 200 OK\r\n"
Expand Down Expand Up @@ -285,7 +285,7 @@ def test_write_info_resp_to_src_failed(self):
self.assertEqual(request.method, "GET")
self.assertEqual(request.version, "HTTP/1.1")
self.assertEqual(request.path, "/chat")
self.assertEqual(request.headers, HttpHeaders([("Host", "localhost"), ("Upgrade", "websocket")]))
self.assertEqual(request.headers, HttpHeaders([("host", "localhost"), ("upgrade", "websocket")]))

self.client_stream.close()

Expand Down
12 changes: 6 additions & 6 deletions microproxy/test/protocol/test_http1.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_on_request(self):

self.assertIsNotNone(self.request)
self.assertEqual(self.request.headers,
HttpHeaders([("Host", "localhost")]))
HttpHeaders([("host", "localhost")]))
self.assertEqual(self.request.method, "GET")
self.assertEqual(self.request.path, "/")
self.assertEqual(self.request.version, "HTTP/1.1")
Expand All @@ -58,8 +58,8 @@ def test_on_response(self):

self.assertIsNotNone(self.response)
self.assertEqual(self.response.headers,
HttpHeaders([("Host", "localhost"),
("Content-Length", "1")]))
HttpHeaders([("host", "localhost"),
("content-length", "1")]))
self.assertEqual(self.response.code, "200")
self.assertEqual(self.response.reason, "OK")
self.assertEqual(self.response.version, "HTTP/1.1")
Expand All @@ -84,8 +84,8 @@ def test_on_info_response(self):

self.assertIsNotNone(self.response)
self.assertEqual(self.response.headers,
HttpHeaders([("Host", "localhost"),
("Upgrade", "websocket")]))
HttpHeaders([("host", "localhost"),
("upgrade", "websocket")]))
self.assertEqual(self.response.code, "101")
self.assertEqual(self.response.reason, "Protocol Upgrade")
self.assertEqual(self.response.version, "HTTP/1.1")
Expand All @@ -104,7 +104,7 @@ def test_on_post_request(self):

self.assertIsNotNone(self.request)
self.assertEqual(self.request.headers,
HttpHeaders([("Host", "localhost"), ("Content-Length", "4")]))
HttpHeaders([("host", "localhost"), ("content-length", "4")]))
self.assertEqual(self.request.method, "POST")
self.assertEqual(self.request.path, "/")
self.assertEqual(self.request.version, "HTTP/1.1")
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
"construct==2.5.3",
"six==1.10.0",
"h2==2.4.0",
"h11==0.5.0+dev",
"h11==0.6.0+dev",
"socks5==0.1.0"
],
dependency_links=[
"https://github.com/chhsiao90/h11/tarball/master#egg=h11-0.5.0+dev",
"https://github.com/njsmith/h11/tarball/master#egg=h11-0.6.0+dev",
"https://github.com/mike820324/socks5/tarball/master#egg=socks5-0.1.0"
],
extras_require={
Expand Down

0 comments on commit 77d2d91

Please sign in to comment.