Scrapy, a fast high-level web crawling & scraping framework for Python.
Response.protocol attribute
Eugenio Lacuesta99cc853d6953
diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.pyindex 1b041c8a8..0f30b01f9 100644--- a/scrapy/core/downloader/handlers/http11.py+++ b/scrapy/core/downloader/handlers/http11.py@@ -442,6 +442,7 @@ class ScrapyAgent:flags=result["flags"],certificate=result["certificate"],ip_address=result["ip_address"],+ protocol=getattr(result["txresponse"], "version", None),)if result.get("failure"):result["failure"].value.response = responsediff --git a/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.pyindex c635fde69..f4ef79c72 100644--- a/scrapy/http/response/__init__.py+++ b/scrapy/http/response/__init__.py@@ -17,8 +17,18 @@ from scrapy.utils.trackref import object_refclass Response(object_ref):- def __init__(self, url, status=200, headers=None, body=b'', flags=None,- request=None, certificate=None, ip_address=None):+ def __init__(+ self,+ url,+ status=200,+ headers=None,+ body=b"",+ flags=None,+ request=None,+ certificate=None,+ ip_address=None,+ protocol=None,+ ):self.headers = Headers(headers or {})self.status = int(status)self._set_body(body)@@ -27,6 +37,7 @@ class Response(object_ref):self.flags = [] if flags is None else list(flags)self.certificate = certificateself.ip_address = ip_address+ self.protocol = protocol@propertydef cb_kwargs(self):@@ -90,7 +101,7 @@ class Response(object_ref):given new values."""for x in ['url', 'status', 'headers', 'body',- 'request', 'flags', 'certificate', 'ip_address']:+ 'request', 'flags', 'certificate', 'ip_address', 'protocol']:kwargs.setdefault(x, getattr(self, x))cls = kwargs.pop('cls', self.__class__)return cls(*args, **kwargs)