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

Bug with relative Location header #875

Closed
jcamiel opened this issue Oct 5, 2022 · 0 comments · Fixed by #883
Closed

Bug with relative Location header #875

jcamiel opened this issue Oct 5, 2022 · 0 comments · Fixed by #883
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Oct 5, 2022

Given the following Hurl file:

redirect.hurl:

# Absolute redirects
GET http://localhost:8000/redirect
HTTP/1.0 302
Location: http://localhost:8000/redirected

GET http://localhost:8000/redirected
HTTP/1.0 200


GET http://localhost:8000/redirect
[Options]
location: true

HTTP/1.0 200
```Redirected```

# Relative redirects
GET http://localhost:8000/relative-redirect
HTTP/1.0 302
Location: /redirected

GET http://localhost:8000/relative-redirect
[Options]
location: true

HTTP/1.0 200
```Redirected```

redirect.py:

from app import app
from flask import redirect, Response


@app.route("/redirect")
def redirectme():
    return redirect("http://localhost:8000/redirected")

@app.route("/relative-redirect")
def relative_redirectme():
    response = Response(status=302)
    response.headers['Location'] = '/redirected'
    response.autocorrect_location_header = False
    return response


@app.route("/redirected")
def redirected():
    return "Redirected"

Hurl is in error:

error: HTTP connection
  --> integration/tests_ok/redirect.hurl:22:5
   |
22 | GET http://localhost:8000/relative-redirect
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (3) URL using bad/illegal format or missing URL
   |

Whereas curl command is ok:

$ curl 'http://localhost:8000/relative-redirect' -L
Redirected

It seems like we have issues with relative Location header. curl seems ok with it and on MDN location can be relative:

A relative (to the request URL) or absolute URL.

@jcamiel jcamiel added the bug Something isn't working label Oct 5, 2022
@fabricereix fabricereix self-assigned this Oct 6, 2022
@fabricereix fabricereix linked a pull request Oct 9, 2022 that will close this issue
@jcamiel jcamiel added this to the 1.8.0 milestone Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants