DCS
DCS

Reputation: 473

HTTP Requests, body vs param vs headers vs data

I am new to HTTP requests (GET, POST, PUT, ETC.) and I am having some issues understanding the "anatomy" of these procedures.

What exactly is the difference between the body and the data? Are they the same thing? Or are headers the same thing as the param? When authentication takes place, are the username and password params or headers or does it vary from API to API? Any help is greatly appreciated. Are there any tutorials or reads you recommend to better understand how to deal with HTTP requests?

Thank you!

Upvotes: 27

Views: 36753

Answers (3)

Hossein Ganjyar
Hossein Ganjyar

Reputation: 823

Based on This article and some points of others, you could find out about differences between HTTP header & HTTP parameter ,and and also Body:

Header:

  • meta data about the request
  • HTTP Headers are NOT part of the URL
  • if it's information about the request or about the client, then the header is appropriate
  • headers are hidden to end-users
  • globally data
  • restrict Dos-attack by detecting authorisation on it's header, because a header can be accessed before the body is downloaded

Param:

  • the query params are within the URL
  • like this "tag=networking&order=newest"
  • if it's the content of the request itself, then it's a parameter
  • The product id and requested image size are examples of "some detail" (or parameter) being supplied as part of the content of a request
  • parameters can be seen by end-users (query parameters) on URL

Body:

  • data of business logic
  • important information
  • unlike body, proxy servers are allowed to modify headers
  • data in specefic kinds of requests
  • you can pass token by body as encoding & decoding in servers

Upvotes: 18

Shihe Zhang
Shihe Zhang

Reputation: 2771

For a full and correct understanding of these questions, RFC2616 recommend by Remy Lebeau is worth reading.

What exactly is the difference between the body and the data?

If you are reading some blog, the body (HTTP body) is be used to transfer data (probably in JSON format). The body carries data, in another way, you get data from body.

Are they the same thing?

So they are not same at all.

Or are headers the same thing as the param?

Header (HTTP header) is related to body, they are part of the HTTP message. As param, it's usually refer to http request param, which usually looks like the following part of the question mark
url?paramName=paramValue&paramTwo=Value2

When authentication takes place, are the username and password params or headers or does it vary from API to API?

They vary for different API's, normally not in param, probably in body of a post request.

Again, start from the RFC2616 would be a good choice.

Upvotes: 1

Evert
Evert

Reputation: 99553

  • data is not a HTTP specific term. data can be anything.
  • a 'parameter' is also not a HTTP specific term. Many web frameworks might consider parameters everything behind the ? in a url, but this is not an absolute truth.
  • usernames and passwords sometimes appear in the request body, sometimes in headers. In web applications they typically are in the request body, but certain types of authentication systems place them in the Authorization header.

Upvotes: 0

Related Questions