tornadoweb / tornadoweb/tornado

WSGIContainer does not support Keep-Alive

Open
#374 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

wsgi
Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Description

Apache Benchmark hangs when setting option -k if using FallbackHandler to a WSGIContainer.

I think the problem is that WSGIContainer does not set a Connection header when the request does not support HTTP 1.1.

Copying the code that sets the headers from RequestHandler.clear to WSGIContainer.__call__ fixes the issue:

        if not request.supports_http_1_1():
            if request.headers.get("Connection", '').lower() == "keep-alive":
                headers.append(("Connection", "Keep-Alive"))

Btw, I have seen some clients sending a lowercase value for Keep-Alive, so I also suggest doing .lower() == "keep-alive" on RequestHandler.clear.

Contributor guide

Open the contributing guide

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.

Research direction

Start at WSGIContainer.call and RequestHandler.clear, comparing their handling of the Connection header for requests that do not support HTTP/1.1. Reproduce the Apache Benchmark case with the -k option and FallbackHandler, then verify that keep-alive requests receive the expected Connection behavior, including lowercase keep-alive values.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.