Honey Honey - 7 months ago 45
HTTP Question

What is the difference between HTTP parameters and HTTP headers?

I read this question but it didn't answer my quesiton.

To me Headers and Parameters are both dictionaries with the difference that headers is

[String : String]
while Parameters is
[String : AnyObject]?
and so if your parameters are also Strings then you could send them within the headers (while using a 'x-' prefix to signify they aren't standard headers) which is a common but not good practice.

  • Is that correct?

  • Are there other difference between

  • What kind of other non-String types would you be sending using


public func request(
method: Method,
_ URLString: URLStringConvertible,
parameters: [String: AnyObject]? = nil,
encoding: ParameterEncoding = .URL,
headers: [String: String]? = nil)
-> Request
return Manager.sharedInstance.request(
parameters: parameters,
encoding: encoding,
headers: headers

As an example I have seen people passing
["x-ios-version" : UIDevice.currentDevice().systemVersion]
or build versions through headers

Loc Loc

Here is the list of differences.

  1. They are designed for different purposes. Headers carry meta info, parameters carry actual data.

  2. HTTP Headers can't carry Unicode content. See here Can I use Unicode characters in HTTP headers?

    BUT parameters can carry Unicode content.

  3. The web server will automatically Un-escape/Decode parameter values. This does not apply for headers.