I read this question but it didn't answer my question.
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.
headers
and parameters
?parameters
?Alamofire Request
method
public func request(
method: Method,
_ URLString: URLStringConvertible,
parameters: [String: AnyObject]? = nil,
encoding: ParameterEncoding = .URL,
headers: [String: String]? = nil)
-> Request
{
return Manager.sharedInstance.request(
method,
URLString,
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
Here is the list of differences:
They are designed for different purposes. Headers carry meta info, parameters carry actual data.
HTTP Servers will automatically un-escape/decode parameter names/values. This does not apply to header names/values.
Header names/values need to be manually escaped/encoded at client side and be manually un-escaped/decoded at server side. Base64 encoding or percent escape is often used.
Parameters can be seen by end-users (in URL), but headers are hidden to end-users.