diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 31f2de26228..174dbc17872 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -372,7 +372,7 @@ jobs: if: >- needs.pre-setup.outputs.upstream-repository-id == github.repository_id runs-on: ubuntu-latest - timeout-minutes: 12 + timeout-minutes: 15 steps: - name: Checkout project uses: actions/checkout@v6 @@ -405,7 +405,7 @@ jobs: uses: CodSpeedHQ/action@v4 with: mode: instrumentation - run: python -Im pytest --no-cov -vvvvv --codspeed + run: python -Im pytest --no-cov -vvvvv --codspeed --durations=30 cython-coverage: diff --git a/CHANGES/12321.misc.rst b/CHANGES/12321.misc.rst new file mode 100644 index 00000000000..71f9db77675 --- /dev/null +++ b/CHANGES/12321.misc.rst @@ -0,0 +1,2 @@ +Added ``cdef`` type declarations and inlined the upgrade check in the HTTP parser +-- by :user:`bdraco`. diff --git a/CHANGES/12561.misc.rst b/CHANGES/12561.misc.rst new file mode 100644 index 00000000000..4201bb90b0d --- /dev/null +++ b/CHANGES/12561.misc.rst @@ -0,0 +1,2 @@ +Bumped the benchmark CI job timeout from 12 to 15 minutes to prevent +spurious failures on slower runners -- by :user:`aiolibsbot`. diff --git a/CHANGES/12562.contrib.rst b/CHANGES/12562.contrib.rst new file mode 100644 index 00000000000..0d89212d365 --- /dev/null +++ b/CHANGES/12562.contrib.rst @@ -0,0 +1 @@ +Added ``--durations=30`` to the benchmark CI run so the slowest tests are reported when the job hits its timeout -- by :user:`aiolibsbot`. diff --git a/CHANGES/12571.contrib.rst b/CHANGES/12571.contrib.rst new file mode 100644 index 00000000000..8fb1b309375 --- /dev/null +++ b/CHANGES/12571.contrib.rst @@ -0,0 +1,4 @@ +Fixed two flakey ``test_middleware_uses_session_avoids_recursion_with_*`` tests +that hard coded ``localhost`` in the inner middleware request; they now target +the bound server URL so happy eyeballs cannot pick an unbound address on +Windows runners -- by :user:`bdraco`. diff --git a/aiohttp/_http_parser.pyx b/aiohttp/_http_parser.pyx index b6dd21fe83a..cd58d7c242a 100644 --- a/aiohttp/_http_parser.pyx +++ b/aiohttp/_http_parser.pyx @@ -457,6 +457,9 @@ cdef class HttpParser: self._has_value = True cdef _on_headers_complete(self): + cdef str h_upg + cdef str enc + self._process_header() http_version = self.http_version() @@ -471,8 +474,7 @@ cdef class HttpParser: if http_version == HttpVersion11 and hdrs.HOST not in headers: raise BadHttpMessage("Missing 'Host' header in request.") h_upg = headers.get("upgrade", "") - allowed = upgrade and h_upg.isascii() and h_upg.lower() in ALLOWED_UPGRADES - if allowed or self._cparser.method == cparser.HTTP_CONNECT: + if (upgrade and h_upg.isascii() and h_upg.lower() in ALLOWED_UPGRADES) or self._cparser.method == cparser.HTTP_CONNECT: self._upgraded = True else: if upgrade and self._cparser.status_code == 101: diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index fea38e954d9..43ff5c75748 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -156,6 +156,7 @@ Indices infos initializer inline +inlined intaking io IoT diff --git a/tests/test_client_middleware.py b/tests/test_client_middleware.py index b9987da6f15..d850b1ed469 100644 --- a/tests/test_client_middleware.py +++ b/tests/test_client_middleware.py @@ -955,7 +955,7 @@ async def log_middleware( if request.url.path != "/log": # Use the session from the request to make the logging call async with request.session.post( - f"http://localhost:{log_server.port}/log", + log_server.make_url("/log"), json={"method": str(request.method), "url": str(request.url)}, ) as resp: assert resp.status == 200 @@ -1023,7 +1023,7 @@ async def log_middleware( # Use the session from the request to make the logging call # Disable middleware to avoid infinite recursion async with request.session.post( - f"http://localhost:{log_server.port}/log", + log_server.make_url("/log"), json={"method": str(request.method), "url": str(request.url)}, middlewares=(), # This prevents infinite recursion ) as resp: