Skip to content
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

HTTPProxyServer should not send Content-Length header in successful responses to CONNECT requests #87

Open
Aetherus opened this issue Jan 26, 2022 · 0 comments

Comments

@Aetherus
Copy link

Aetherus commented Jan 26, 2022

According to RFC7231,

A server MUST NOT send any Transfer-Encoding or Content-Length header fields in a 2xx (Successful) response to CONNECT.

However, I tried the example code on https://docs.ruby-lang.org/en/2.2.0/WEBrick/HTTPProxyServer.html

require 'webrick'
require 'webrick/httpproxy'

proxy = WEBrick::HTTPProxyServer.new Port: 8000

trap 'INT'  do proxy.shutdown end
trap 'TERM' do proxy.shutdown end

proxy.start

and sent a request through this proxy

$ ALL_PROXY=http://localhost:8000 curl -I https://www.google.com/

and it showed

HTTP/1.1 200 OK
Server: WEBrick/1.7.0 (Ruby/3.1.0/2021-12-25)
Date: Wed, 26 Jan 2022 03:48:33 GMT
Content-Length: 0
Connection: close

...

You can see the Content-Length header is there, and it does cause problems for some kinds of clients.

@Aetherus Aetherus changed the title HTTPProxyServer should not return Content-Length header in successful responses to CONNECT requests HTTPProxyServer should not send Content-Length header in successful responses to CONNECT requests Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant