Skip to content

Don't explicitly sent Connection: close to upstream #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
abhinavsingh opened this issue Sep 21, 2019 · 0 comments
Closed

Don't explicitly sent Connection: close to upstream #75

abhinavsingh opened this issue Sep 21, 2019 · 0 comments
Assignees

Comments

@abhinavsingh
Copy link
Owner

abhinavsingh commented Sep 21, 2019

Without proxy.py using telnet

$ telnet httpbin.org 80
Trying 3.219.197.134...
Connected to httpbin.org.
Escape character is '^]'.
GET /get HTTP/1.1
Host: httpbin.org

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sat, 21 Sep 2019 22:28:28 GMT
Referrer-Policy: no-referrer-when-downgrade
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Length: 146
Connection: keep-alive

{
  "args": {}, 
  "headers": {
    "Host": "httpbin.org"
  }, 
  "origin": "1.2.3.4, 1.2.3.5", 
  "url": "https://httpbin.org/get"
}

^^^ Above connection hasn't dropped. As evident from server response Connection: keep-alive. Now, we can continue requesting further data over same connection until server drops the connection due to client inactivity or other reasons.

GET /get HTTP/1.1
Host: httpbin.org

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sat, 21 Sep 2019 22:28:38 GMT
Referrer-Policy: no-referrer-when-downgrade
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Length: 146
Connection: keep-alive

{
  "args": {}, 
  "headers": {
    "Host": "httpbin.org"
  }, 
  "origin": "1.2.3.4, 1.2.3.5", 
  "url": "https://httpbin.org/get"
}
^]
telnet> quit
Connection closed.

With proxy.py using telnet

Same behavior doesn't work when pointing telnet to proxy.py

$ telnet localhost 8899
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET http://httpbin.org/get HTTP/1.1
Host: httpbin.org

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sat, 21 Sep 2019 22:34:11 GMT
Referrer-Policy: no-referrer-when-downgrade
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Length: 146
Connection: Close

{
  "args": {}, 
  "headers": {
    "Host": "httpbin.org"
  }, 
  "origin": "1.2.3.4, 1.2.3.5", 
  "url": "https://httpbin.org/get"
}
^]
telnet> quit
Connection closed.

^^^ As evident from server header Connection: Close, connection was dropped by the server. Same can also be verified from proxy.py logs.

This is happening because currently proxy.py explicitly adds a Connection: Close header when sending requests to upstream server. We should fix this and only use Connection: Close if client has explicitly requested the same.

Cross reference https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant