Fix redirection not followed with 'location' header.

This commit is contained in:
jcamiel 2022-05-06 14:47:25 +02:00 committed by Fabrice Reix
parent 0d6b1cb7a0
commit 810089bd2a
3 changed files with 14 additions and 3 deletions

View File

@ -68,6 +68,7 @@ def test(hurl_file):
env[name] = value
cmd = ["hurl", hurl_file] + options
# cmd = ["cargo", "run", "--bin", "hurl", "--", hurl_file] + options
print(" ".join(cmd))
result = subprocess.run(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env

View File

@ -1,5 +1,5 @@
from app import app
from flask import redirect
from flask import redirect, Response
@app.route("/follow-redirect")
@ -9,7 +9,17 @@ def follow_redirect():
@app.route("/following-redirect")
def following_redirect():
return redirect("http://localhost:8000/followed-redirect")
# For this redirection, we construct the response instead of using
# Flask `redirect` function to make a redirection with a 'location' header (instead of 'Location').
response = Response(
response="<!DOCTYPE html>\n"
"<title>Redirecting...</title>\n"
"<h1>Redirecting...</h1>\n",
status=302,
mimetype="text/html",
)
response.headers["location"] = "http://localhost:8000/followed-redirect"
return response
@app.route("/followed-redirect")

View File

@ -151,7 +151,7 @@ pub fn get_header_values(headers: &[Header], expected_name: &str) -> Vec<String>
headers
.iter()
.filter_map(|Header { name, value }| {
if name == expected_name {
if name.to_lowercase() == expected_name.to_lowercase() {
Some(value.to_string())
} else {
None