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

Allow relative URI in redirection #414

Open
ivmfnal opened this issue Jun 28, 2020 · 0 comments
Open

Allow relative URI in redirection #414

ivmfnal opened this issue Jun 28, 2020 · 0 comments

Comments

@ivmfnal
Copy link

ivmfnal commented Jun 28, 2020

RFC 7231 allows for relative URI in the redirection response: https://tools.ietf.org/html/rfc7231#section-7.1.2

However, WebOb converts relative URI to absolute before sending the response. It is done when using HTTPFound, HTTPMovedPermanently exceptions or when using Response with Location header.

Here are pieces of code which demonstrate that. This code is not using any web server. It is pure Python WSGI reference implementation

from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server

from webob import Response

def app(environ, start_response):
    headers = [('Location', './new_page')]
    r = Response("redirected", status=301, headers=headers)
    return r(environ, start_response)

httpd = make_server('', 8000, app)
httpd.serve_forever()
from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server

from webob.exc import HTTPMovedPermanently

def app(environ, start_response):
    r = HTTPMovedPermanently(location='./new_page')
    return r(environ, start_response)

httpd = make_server('', 8000, app)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants