Cookie having a Domain cookie-attribute with empty string fails to be added to the cookie jar
まだ誰も着手していません。
評価
調査の方向性
提供されているTestMissingSessionCookieIssueの再現コードとsession.cookies.extract_cookiesエントリーポイントから始めます。両方のテストメソッドを実行し、ドメインなしの場合と空のドメインの場合を比較します。期待される結果どおり、domain=;属性を持つcookieがcookie jarに追加されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Using requests to access an API hosted on an application server we noticed that cookies were not added to the cookie jar in the session.
It seems that after an upgrade to the application server framework it adds a domain=; cookie-attribute to the cookies in the response.
Expected Result
The cookie to be added to the jar
Actual Result
The cookie is dropped.
Reproduction Steps
import unittest
from typing import Tuple
from unittest.mock import MagicMock
import requests
from hamcrest import assert_that, has_length
class TestMissingSessionCookieIssue(unittest.TestCase):
@staticmethod
def __make_mocks(cookie_header_value: str) -> Tuple[MagicMock, MagicMock]:
message = MagicMock()
message.get_all.side_effect = [[], [cookie_header_value]]
response = MagicMock()
response.info.return_value = message
request = MagicMock()
request.get_full_url.return_value = "http://localhost:1234/page"
request.origin_req_host = "localhost"
return request, response
def test_cookie_with_no_domain(self) -> None:
request, response = self.__make_mocks("SESSION_ID=12345678; HttpOnly; Path=/page; SameSite=Strict")
session = requests.session()
session.cookies.extract_cookies(response, request)
assert_that(session.cookies, has_length(1))
def test_cookie_with_empty_domain(self) -> None:
request, response = self.__make_mocks("SESSION_ID=12345678; domain=; path=/page; samesite=strict; httponly")
session = requests.session()
session.cookies.extract_cookies(response, request)
assert_that(session.cookies, has_length(1))
Requirements:
PyHamcrest==2.0.2requests==2.28.1- Python 3.9
System Information
$ python -m requests.help
{
"chardet": {
"version": null
},
"charset_normalizer": {
"version": "2.0.12"
},
"cryptography": {
"version": ""
},
"idna": {
"version": "3.4"
},
"implementation": {
"name": "CPython",
"version": "3.9.5"
},
"platform": {
"release": "5.14.0-1052-oem",
"system": "Linux"
},
"pyOpenSSL": {
"openssl_version": "",
"version": null
},
"requests": {
"version": "2.28.1"
},
"system_ssl": {
"version": "1010106f"
},
"urllib3": {
"version": "1.26.12"
},
"using_charset_normalizer": true,
"using_pyopenssl": false
}
- 主要言語
- Python
- スター
- 54.7k
- フォーク
- 10.8k
- 平均マージ
- 18分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
psf/requests のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
`iter_lines(decode_unicode=True, delimiter=<str>)` raises `TypeError` when `Response.encoding` is `None`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
get_encoding_from_headers treats any content type containing 'text' as text/* (ISO-8859-1)対応中かも @suyashgitt が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Invalid `params` type (e.g. int) raises misleading "TypeError: Cannot mix str and non-str arguments"オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
似ている issue
-
documentation type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
add entry to blockオープン
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"対応中かも @0z5a が今日担当しました。 オープンneeds-triage
難易度 2/5 半日 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2x対応中かも @Shizoqua が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/TokenEconomizer#221 ·
メンテナーはふだん 1 日以内に返信
-
plot_graph crashes when a mesh node has no m2m edge対応中かも @tygvi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mllam/neural-lam#883 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信