aaronpowell / httpstatus

Easily generate different HTTP responses for testing
http://httpstat.us
MIT License
702 stars 74 forks source link

`HTTP/1.1 500 Internal Server Error` occurs when `X-HttpStatus-Response-Location` is set #136

Closed WangYihang closed 4 months ago

WangYihang commented 1 year ago

Description

I wanted to generate an HTTP 302 redirection response via httpstatus.us, but got a 500 Internal Server Error when I set both the status code and the Location header for the response.

301, 303, 305, 307, and 308 will also return 500.

Expected Behaviour

$ curl httpstat.us/302 -H "X-HttpStatus-Response-Location: https://www.google.com/" -vv
*   Trying 20.40.202.3:80...
* Connected to httpstat.us (20.40.202.3) port 80 (#0)
> GET /302 HTTP/1.1
> Host: httpstat.us
> User-Agent: curl/7.88.1
> Accept: */*
> X-HttpStatus-Response-Location: https://www.google.com/
> 
< HTTP/1.1 302 Found
< Content-Length: 6
< Content-Type: text/plain
< Date: Thu, 14 Sep 2023 13:52:43 GMT
< Server: Kestrel
< Location: https://www.google.com/
* Connection #0 to host httpstat.us left intact

Current Behaviour

$ curl httpstat.us/302 -H "X-HttpStatus-Response-Location: https://www.google.com/" -vv
*   Trying 20.40.202.3:80...
* Connected to httpstat.us (20.40.202.3) port 80 (#0)
> GET /302 HTTP/1.1
> Host: httpstat.us
> User-Agent: curl/7.88.1
> Accept: */*
> X-HttpStatus-Response-Location: https://www.google.com/
> 
< HTTP/1.1 500 Internal Server Error
< Content-Length: 0
< Date: Thu, 14 Sep 2023 13:52:55 GMT
< Server: Kestrel
* Connection #0 to host httpstat.us left intact
brmonaghan commented 6 months ago

Same here, cant get on now! 😠

thomasjtaylor commented 4 months ago

The Location header appears to be set correctly for non-3xx status codes.

curl http://httpstat.us/200 -H "X-HttpStatus-Response-Location: https://httpstat.us/301" -vv
*   Trying 20.40.202.3:80...
* Connected to httpstat.us (20.40.202.3) port 80
> GET /200 HTTP/1.1
> Host: httpstat.us
> User-Agent: curl/8.4.0
> Accept: */*
> X-HttpStatus-Response-Location: https://httpstat.us/301
>
< HTTP/1.1 200 OK
< Content-Length: 6
< Content-Type: text/plain
< Date: Fri, 17 May 2024 13:42:24 GMT
< Server: Kestrel
< Location: https://httpstat.us/301
< Set-Cookie: ARRAffinity=c38d24fc71835a4381b70cf88d3a3a31350c58e4caa72063abf82ef0ba9df09a;Path=/;HttpOnly;Domain=httpstat.us
< Request-Context: appId=cid-v1:3548b0f5-7f75-492f-82bb-b6eb0e864e53
<
200 OK* Connection #0 to host httpstat.us left intact