HTTP status for directories
Valentin V. Bartenev
vbart at nginx.com
Fri Mar 4 00:57:52 UTC 2022
On Friday, 4 March 2022 03:41:28 MSK Alejandro Colomar (man-pages) wrote:
> Hi Valentin,
>
> As I finished the implementation of "index" supporting an empty array, I
> did some deep testing, and got something interesting. It works as
> expected, but there's still something that may not be what we want.
>
> When a dir is requested, the behavior is different right now for the
> following two cases:
>
> user at ADY-debian-11:~/src/nginx/unit$ curl --dump-header - localhost/dir
> HTTP/1.1 301 Moved Permanently
> Location: /dir/
> Server: Unit/1.27.0
> Date: Thu, 03 Mar 2022 23:58:58 GMT
> Content-Length: 0
>
> user at ADY-debian-11:~/src/nginx/unit$ curl --dump-header - localhost/dir/
> HTTP/1.1 404 Not Found
> Content-Type: text/html
> Server: Unit/1.27.0
> Date: Thu, 03 Mar 2022 23:59:01 GMT
> Content-Length: 54
>
> <!DOCTYPE html><title>Error 404</title><p>Error 404.
>
>
> The redirect makes sense, but we're not showing the 404 page after the
> redirection. It serves 0 bytes. Is that correct?
[..]
It serves 0 bytes for the "301 Moved Permanently", which is ok as any
payload for the 301 code isn't displayed in browsers anyway.
What do you mean by not showing the 404 page? The "curl" command just
doesn't follow the redirect by default. In order to instruct curl to
follow redirctions, you need to specify the -L option:
curl -L localhost/dir
--
Valentin
More information about the unit
mailing list