Override "Connection" in headers will result in two "Connection" in headers.
See original GitHub issueIf I try to override the “Connection” in the headers with either custome_settings
custom_settings = {
'DEFAULT_REQUEST_HEADERS': {
'Connection' : 'Keep-Alive'
}
}
or within the request headers
headers = {}
headers['Connection'] : 'Keep-Alive'
headers['User-Agent'] : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'
for url in urls:
yield scrapy.Request(url, headers=headers, callback = self.parse)
It will result with a request with two "Connection"s in the header.
GET http://example.com HTTP/1.1
Connection: close
Connection: Keep-Alive
User-Agent: Scrapy/1.4.0 (+http://scrapy.org)
Accept-Encoding: gzip,deflate
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to override "Connection : close" in header Scrapy?
Show activity on this post. However the request is not overriding the value. Instead it is just appending another "Connection" into the request ......
Read more >Connection - HTTP - MDN Web Docs
The Connection general header controls whether the network connection stays open after the current transaction finishes.
Read more >HTTP headers | Connection - GeeksforGeeks
The HTTP Connection header is a general type header that allows the sender or client to specify options that are desired for that...
Read more >respond iRule command sends double Connection headers in ...
This is the result of a known issue. The HTTP::respond iRule command sends double Connection headers when using a user-specified Connection: ...
Read more >HTTP header manipulation - Envoy Proxy
The HTTP connection manager manipulates several HTTP headers both during decoding ... or an https scheme over an unencrypted connection will result in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey folks, I fired up Wireshark and tried to reproduce this, with no success, on Python 3.5 and Scrapy 1.5.0.
If I issue the following:
…then I see in Wireshark the following request firing:
(I did try sending ‘keep-alive’ first, and that also works as expected. I just felt like mixing it up a bit).
Interestingly, and disappointingly, the response from
httpbin.org/headers
always includes the header ‘Connection: close’, reducing its usefulness for debugging this issue.Can anyone provide me with a reproducible test case so I can further test this?
@cathalgarvey in a link @tlinhart posted (https://github.com/scrapy/scrapy/issues/2970#issuecomment-360706840) Connection header is set only when body is not None. So it affects POST, PUT and other requests with non-empty bodies; it doesn’t affect usual GET requests, which your Wireshark experiment shows. Though it uses .setdefault, so it shoudn’t override an existing header value…