Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

rest - Payloads of HTTP Request Methods

The Wikipedia entry on HTTP lists the following HTTP request methods:

  • HEAD: Asks for the response identical to the one that would correspond to a GET request, but without the response body.
  • GET: Requests a representation of the specified resource.
  • POST: Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request.
  • PUT: Uploads a representation of the specified resource.
  • DELETE: Deletes the specified resource.
  • TRACE: Echoes back the received request, so that a client can see what (if any) changes or additions have been made by intermediate servers.
  • OPTIONS: Returns the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource.
  • CONNECT: Converts the request connection to a transparent TCP/IP tunnel, usually to facilitate SSL-encrypted communication (HTTPS) through an unencrypted HTTP proxy.
  • PATCH: Is used to apply partial modifications to a resource.

I'm interested in knowing (specifically regarding the first five methods):

  • which of these methods are able (supposed to?) receive payloads
    • of the methods that can receive payloads, how do they receive it?
      • via query string in URL?
      • via URL-encoded body?
      • via raw / chunked body?
      • via a combination of ([all / some] of) the above?

I appreciate all input, if you could share some (preferably light) reading that would be great too!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is the summary from RFC 7231, an updated version of the link @Darrel posted:

  • HEAD - No defined body semantics.
  • GET - No defined body semantics.
  • PUT - Body supported.
  • POST - Body supported.
  • DELETE - No defined body semantics.
  • TRACE - Body not supported.
  • OPTIONS - Body supported but no semantics on usage (maybe in the future).
  • CONNECT - No defined body semantics

As @John also mentioned, all request methods support query strings in the URL (one notable exception might be OPTIONS which only seems to be useful [in my tests] if the URL is HOST/*).

I haven't tested the CONNECT and PATCH methods since I have no interest in them ATM.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...