Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP requests and querystring vs headers?

Tags:

rest

http

I'm trying to understand the difference between querystrings and headers. Where do you use each?

Query strings might be more useful in making URLs human readable I suppose, but other than that, wouldn't it be easier to just embed that in your own custom HTTP header (side question, but how this relate to cookies?)? What's the distinction between the two?

like image 725
randomafk Avatar asked Jun 06 '12 03:06

randomafk


People also ask

Is a query parameter the same as a header?

From the security point of view, there's no difference on using HTTP Header vs Query Param since both are encrypted when using TLS/SSL. But query params can be more fragile since it can be easily visible in browsers, are logged across the board by default (browser history, web servers access logs and etc).

What are headers in HTTP requests?

An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate it's preferred media formats, while a response can use header to indicate the media format of the returned body.

What is a QueryString used for?

A querystring is a set of characters input to a computer or Web browser and sent to a query program to recover specific information from a database .


1 Answers

Refer a similar question Adding Custom HTTP Headers

Why would I prefer query string over http-header fields?

  1. It is easy
  2. I don't need any additional API
  3. It is also recommended in HTTP-RFC to "follow common-forms" when it comes to header fields.
like image 164
Ahamed Mustafa M Avatar answered Nov 05 '22 12:11

Ahamed Mustafa M