HTTP method names: upper or lower case?
Asked Answered
L

2

18

This may be a self-answering question, but I'm hoping one of you could point me to any resource where it is declared, or can be inferred, whether to use upper or lower case letters when declaring an HTTP method name in HTTP or REST requests. The majority of examples I see put GET, PUT, POST, DELETE, PATCH etc in capital letters, whereas I go on the assumption that HTTP method field names are case insensitive - that is, for example, that "get" is equally as valid as "GET". Traditionally, I have always used capital letters, but I would just like to be sure.

The W3C explicitly declares that the method is case-sensitive and uses upper case, but in my travails, I've often encountered HTTP method field values using lower case, which I assume are incorrect, so from my point of view, it seems that practices and standards are somewhat out of touch on this matter.

Upper case is correct - right?

Laciniate answered 11/12, 2014 at 13:5 Comment(2)
What further resources could you want other than the spec?Gorilla
Maybe HTTP is the less respected protocol in this world...Keyboard
O
32

Method names are case-sensitive, and all registered methods are all upper-case.

(and the W3C really doesn't matter here; what's relevant are RFCs 7230 and 7231).

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

Orphrey answered 11/12, 2014 at 16:10 Comment(2)
Thanks for the golden grail - RFC 7230 and 7231 it is. Thanks Julian :)Laciniate
@polythene - that simply means that you could define a method "get" (or "Get"), which would be different from the GET method defined in the HTTP specifications.Orphrey
S
1

yes as "Julian Reschk" said it should be upper-case by convention.

if you are using server like Django, Flask or Express (node) directly then your lower-case method names will be translated to upper-case automatically. Frontent <---> Backend

but if there is a proxy in-between then it will a problem like nginx then you will get an error, also most services on cloud platforms like AWS, GCP, Azure use nginx behind the scenes. you will probably run in to this issue.

Sorehead answered 22/8, 2022 at 8:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.