rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

HEAD requests return 'Method Not Allowed'

Open jyn514 opened this issue 4 years ago • 1 comments

$ curl -I 'https://play.rust-lang.org/'
HTTP/1.1 405 Method Not Allowed

According to RFC 7231,

The HEAD method is identical to GET except that the server MUST NOT send a message body in the response (i.e., the response terminates at the end of the header section). The server SHOULD send the same header fields in response to a HEAD request as it would have sent if the request had been a GET, except that the payload header fields (Section 3.3) MAY be omitted. This method can be used for obtaining metadata about the selected representation without transferring the representation data and is often used for testing hypertext links for validity, accessibility, and recent modification.

This causes cargo-deadlinks and linkcheck to report any playground URLs as dead links.

Is this intentional? Most major web frameworks I know will handle HEAD for you automatically.

jyn514 avatar Jan 05 '21 01:01 jyn514

Also, there's no Allow header:

HTTP/1.1 405 Method Not Allowed
Server: nginx/1.14.0 (Ubuntu)
Date: Tue, 05 Jan 2021 01:21:43 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: keep-alive
Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers

https://tools.ietf.org/html/rfc7231#section-6.5.5 says

The 405 (Method Not Allowed) status code indicates that the method received in the request-line is known by the origin server but not supported by the target resource. The origin server MUST generate an Allow header field in a 405 response containing a list of the target resource's currently supported methods.

jyn514 avatar Jan 05 '21 01:01 jyn514