Are HTTP methods case sensitive?
Asked Answered
S

1

11

To ask a question related to Are HTTP headers case-sensitive?, if HTTP methods are case sensitive, what do most servers do with a "get" or "post" vs a "GET" or "POST"?

For example, it looks like Apache httpd returns "501 Method Not Implemented" in response to lowercase methods, which is what I would expect.

Stupe answered 5/5, 2018 at 16:41 Comment(4)
Methods are indeed case-sensitive (w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1)Claret
@OliverCharlesworth rfc2616 is obsolete, tools.ietf.org/html/rfc7230#section-3.1.1 is the current text -- the point you made stands: methods are case-sensitive.Mucin
Is this question body answerable as written? It seems to request the behavior of "most servers" for conditions that are provably out of spec. Furthermore, the bounty requests an official reference for this undefined behavior, which seems to be either self-contradictory or a list of all major server implementations (and their chosen failure modes) to approximate the question's "most servers".Nihhi
Does this answer your question? HTTP method names: upper or lower case?Keever
H
4

The method token indicates the request method to be performed on the target resource. The request method is case-sensitive.

https://www.rfc-editor.org/rfc/rfc7230#section-3.1.1

The method token is case-sensitive because it might be used as a gateway to object-based systems with case-sensitive method names.

https://www.rfc-editor.org/rfc/rfc7231#section-4.1

What is interesting, is that while both references say the case is important, neither one says what case should be used. Continuing from the second reference:

By convention, standardized methods are defined in all-uppercase US-ASCII letters.

So now here it does say uppercase, but it also says by convention. So on paper, it would seem that you could also use all lower. In practice, it seems only upper is accepted:

PS C:\> curl.exe -X POST https://www.ietf.org
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="robots" content="NONE,NOARCHIVE">
  <title>403 Forbidden</title>
PS C:\> curl.exe -X post https://www.ietf.org
<html>
<head><title>400 Bad Request</title></head>
Heimlich answered 12/3, 2021 at 23:29 Comment(1)
Case-sensitive just means that you have to use the name as specified, without changing the case. The method names are specified as POST, GET, and so on, so there's no ambiguity here.Synapsis

© 2022 - 2024 — McMap. All rights reserved.