tornadoweb / tornadoweb/tornado

relative URIs in Location header

Open
#3,067 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The old specification of HTTP defined the values of a Location header to be absolute URI's.

https://datatracker.ietf.org/doc/html/rfc2616#section-14.30

Location = "Location" ":" absoluteURI

Nowadays, because there are so many broken implementations, relative URI's seem to be allowed as well:

https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.2

Location = URI-reference

Sometimes this leads to errors.

Wouldn't it be better if tornado completes the URI or at least give a chance to do it?

For example I expected self.reverse_url() to return an absolute URI or at least that self.redirect() does that for me.

useful would be to add:

    def reverse_absolute_url(self, name, *args):
        return self.request.protocol + "://" + self.request.host + self.reverse_url(name, *args)

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 by tracing the behavior of self.reverse_url() and self.redirect(), then compare their handling of relative Location values with the RFC 7231 and RFC 2616 references in the issue. Done requires an agreed approach for absolute or relative URI handling and corresponding behavior in the affected entry points.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.