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

Open
#87 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
networking

Research direction

Start by running the WEBrick::HTTPProxyServer example and the provided curl command to reproduce the header. Then trace the HTTPProxyServer handling of CONNECT responses. Done means successful 2xx CONNECT responses no longer include Content-Length or Transfer-Encoding, consistent with RFC7231.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Ruby
Stars
328
Forks
114
Avg merge
1h 15m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/webrick

All issues in ruby/webrick

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.