If a header appears multiple times, only the last one is used. To send a header multiple times, pass a tuple of values.
verify_ssl: bool, whether the SSL/TLS certificate should be validated
timeout: int or float, how long the fetch may take at most in total (sending request until finishing reading the response)
fromResponse: ClientResponse or None; if provided, use fromResponse.url for the url completion (instead of self.baseUrl) and add it as a Referer header
Returns response (a ClientResponse object or a qwarc.utils.DummyClientResponse object)
'''
@@ -96,13 +100,16 @@ class Item:
url = yarl.URL(url) # Explicitly convert for normalisation, percent-encoding, etc.
if not url.scheme or not url.host:
if not self.baseUrl:
if fromResponse is not None:
url = fromResponse.url.join(url)
elif not self.baseUrl:
raise ValueError('Incomplete URL and no baseUrl to join it with')
url = self.baseUrl.join(url)
else:
url = self.baseUrl.join(url)
if responseHandler is None:
responseHandler = self.defaultResponseHandler
assert method in ('GET', 'POST'), 'method must be GET or POST'
headers = self._merge_headers(headers)
headers = self._merge_headers(headers, extraHeaders = [('Referer', str(fromResponse.url))] if fromResponse is not None else [])