Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are HTTP methods case sensitive?

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.

like image 342
wsanders Avatar asked May 05 '18 16:05

wsanders


1 Answers

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>
like image 107
Zombo Avatar answered Sep 17 '22 01:09

Zombo