From 989c558e05c846cecd74449a66134f9be85709e7 Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 28 Jun 2024 11:29:32 +0800 Subject: [PATCH] =?UTF-8?q?4.0.5.4=E4=BF=AE=E5=A4=8DSessionPage=E7=9A=84he?= =?UTF-8?q?aders=E8=AE=BE=E7=BD=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 2 +- DrissionPage/_pages/session_page.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index 9bb8baf..e173e0d 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -14,4 +14,4 @@ from ._configs.chromium_options import ChromiumOptions from ._configs.session_options import SessionOptions __all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__'] -__version__ = '4.0.5.3' +__version__ = '4.0.5.4' diff --git a/DrissionPage/_pages/session_page.py b/DrissionPage/_pages/session_page.py index 4f699c8..94a7d07 100644 --- a/DrissionPage/_pages/session_page.py +++ b/DrissionPage/_pages/session_page.py @@ -292,23 +292,25 @@ class SessionPage(BasePage): """ kwargs = CaseInsensitiveDict(kwargs) if 'headers' not in kwargs: - kwargs['headers'] = {} + kwargs['headers'] = CaseInsensitiveDict() else: kwargs['headers'] = CaseInsensitiveDict(format_headers(kwargs['headers'])) # 设置referer和host值 parsed_url = urlparse(url) - hostname = parsed_url.hostname + hostname = parsed_url.netloc scheme = parsed_url.scheme if not check_headers(kwargs['headers'], self._headers, 'Referer'): kwargs['headers']['Referer'] = self.url if self.url else f'{scheme}://{hostname}' - if 'Host' not in kwargs['headers']: + if not check_headers(kwargs['headers'], self._headers, 'Host'): kwargs['headers']['Host'] = hostname - if not check_headers(kwargs, self._headers, 'timeout'): kwargs['timeout'] = self.timeout - kwargs['headers'] = {**self._headers, **kwargs['headers']} + h = CaseInsensitiveDict(self._headers) + for k, v in kwargs['headers'].items(): + h[k] = v + kwargs['headers'] = h r = err = None retry = retry if retry is not None else self.retry_times