Merge pull request !48 from g1879/dev
This commit is contained in:
g1879 2024-06-28 03:31:49 +00:00 committed by Gitee
commit 67e8ede874
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 6 deletions

View File

@ -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'

View File

@ -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