Skip to content

Commit

Permalink
Use httpx for wptserve tests instead of hyper
Browse files Browse the repository at this point in the history
hyper is no longer maintained, and doesn't work with Python 3.10.

The vendored hyper is removed entirely, and replaced by httpx installed
using pip.

Tests are updated, mostly in trivial ways. A few cases are interesting:

 - When httpx is used to POST, `handle_data` ends up called two times
   instead of once, first with the data, and then with an empty byte
   string. Whether this is an httpx bug or not, test_h2_data.py and
   test_h2_headers_data.py are adapted to deal with this, and changed to
   case-swap the input instead so that no buffering is needed.

 - `test_encode` previously failed an assert in the handler, but the
   response wasn't checked at all, so this wasn't noticed.

 - `test_push` is dropped since it can't be tested using httpx.

 - `test_raw_header_frame_invalid` is dropped since it ends up testing
   the error handling of the client, and httpx doesn't treat this input
   as an error. A better test would just check what bytes were sent over
   the wire, but don't bother, it's more work than seems justified.

 - `test_http_version` is added to make sure these tests keep using
   HTTP/2 even if httpx behavior changes in the future.

Fixes #28784.
Fixes #31315.
  • Loading branch information
foolip committed Mar 18, 2022
1 parent 378ce87 commit 0cbae85
Show file tree
Hide file tree
Showing 66 changed files with 92 additions and 18,844 deletions.
2 changes: 0 additions & 2 deletions fetch/api/resources/echo-content.h2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from wptserve.utils import isomorphic_encode

def handle_headers(frame, request, response):
response.status = 200
response.headers.update([('Content-Type', 'text/plain')])
Expand Down
1 change: 1 addition & 0 deletions tools/requirements_tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
httpx[http2]==0.22.0
json-e==4.4.3
jsonschema==3.2.0
pyyaml==6.0
Expand Down
36 changes: 0 additions & 36 deletions tools/third_party/hyper/hyper/__init__.py

This file was deleted.

5,116 changes: 0 additions & 5,116 deletions tools/third_party/hyper/hyper/certs.pem

This file was deleted.

264 changes: 0 additions & 264 deletions tools/third_party/hyper/hyper/cli.py

This file was deleted.

7 changes: 0 additions & 7 deletions tools/third_party/hyper/hyper/common/__init__.py

This file was deleted.

Loading

0 comments on commit 0cbae85

Please sign in to comment.