Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/12088.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed tests to pass when run after 2027-05-31 -- by :user:`bmwiedemann`.
19 changes: 10 additions & 9 deletions aiohttp/client_proto.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import asyncio
from contextlib import suppress
from typing import Any, Callable
from typing import Callable, Protocol

from ._websocket.reader import WebSocketDataQueue
from .base_protocol import BaseProtocol
from .client_exceptions import (
ClientConnectionError,
Expand All @@ -14,6 +15,7 @@
_EXC_SENTINEL,
EMPTY_BODY_STATUS_CODES,
BaseTimerContext,
ErrorableProtocol,
set_exception,
set_result,
)
Expand All @@ -22,6 +24,10 @@
from .streams import EMPTY_PAYLOAD, DataQueue, StreamReader


class _Payload(ErrorableProtocol, Protocol):
def is_eof(self) -> bool: ...


class ResponseHandler(BaseProtocol, DataQueue[tuple[RawResponseMessage, StreamReader]]):
"""Helper class to adapt between Protocol and StreamReader."""

Expand All @@ -31,7 +37,7 @@ def __init__(self, loop: asyncio.AbstractEventLoop) -> None:

self._should_close = False

self._payload: StreamReader | None = None
self._payload: _Payload | None = None
self._skip_payload = False
self._payload_parser: WebSocketReader | None = None
self._data_received_cb: Callable[[], None] | None = None
Expand Down Expand Up @@ -206,15 +212,10 @@ def set_exception(

def set_parser(
self,
parser: Any,
payload: Any,
parser: WebSocketReader,
payload: WebSocketDataQueue,
data_received_cb: Callable[[], None] | None = None,
) -> None:
# TODO: actual types are:
# parser: WebSocketReader
# payload: WebSocketDataQueue
# but they are not generi enough
# Need an ABC for both types
self._payload = payload
self._payload_parser = parser
self._data_received_cb = data_received_cb
Expand Down
20 changes: 10 additions & 10 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -5450,30 +5450,30 @@ async def handler(request: web.Request) -> web.Response:
# Simulate Amazon-like cookies from the issue
cookies = [
"session-id=146-7423990-7621939; Domain=.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; "
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; "
"Secure; HttpOnly",
"session-id=147-8529641-8642103; Domain=.www.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; HttpOnly",
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; HttpOnly",
"session-id-time=2082758401l; Domain=.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; Secure",
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; Secure",
"session-id-time=2082758402l; Domain=.www.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/",
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/",
"ubid-acbit=257-7531983-5395266; Domain=.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; Secure",
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; Secure",
'x-acbit="KdvJzu8W@Fx6Jj3EuNFLuP0N7OtkuCfs"; Version=1; '
"Domain=.amazon.it; Path=/; Secure; HttpOnly",
"at-acbit=Atza|IwEBIM-gLr8; Domain=.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; "
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; "
"Secure; HttpOnly",
'sess-at-acbit="4+6VzSJPHIFD/OqO264hFxIng8Y="; '
"Domain=.amazon.it; Expires=Mon, 31-May-2027 10:00:00 GMT; "
"Domain=.amazon.it; Expires=Mon, 31-May-3024 10:00:00 GMT; "
"Path=/; Secure; HttpOnly",
"lc-acbit=it_IT; Domain=.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/",
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/",
"i18n-prefs=EUR; Domain=.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/",
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/",
"av-profile=null; Domain=.amazon.it; "
"Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; Secure",
"Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; Secure",
'user-pref-token="Am81ywsJ69xObBnuJ2FbilVH0mg="; '
"Domain=.amazon.it; Path=/; Secure",
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ def test_update_cookies_from_headers_with_attributes() -> None:
"secure-cookie=value1; Secure; HttpOnly; SameSite=Strict",
"expiring-cookie=value2; Max-Age=3600; Path=/app",
"domain-cookie=value3; Domain=.example.com; Path=/",
"dated-cookie=value4; Expires=Wed, 09 Jun 2030 10:18:14 GMT",
"dated-cookie=value4; Expires=Wed, 09 Jun 3024 10:18:14 GMT",
]

jar.update_cookies_from_headers(headers, url)
Expand Down
Loading