ios - Difference between setting an NSMutableURLRequest header and adding one -
i wondering difference between setting header value , adding header value nsmutableurlrequest is. sounds sort of obvious but, example, can't use addvalue every time? setting header doesn't exist throw error? adding header when exists in request overwrite existing value?
example
let request.nsmutableurlrequest(url: nsurl(string: "someurl")!) request.addvalue("application/json", forhttpheaderfield: "content-type") ...
i think discussion in apple's official doc quite clear:
this method provides ability add values header fields incrementally. if value set specified field, supplied value appended existing value using appropriate field delimiter. in case of http, delimiter comma.
the new value header field. existing value field replaced new value.
setvalue
replaces. addvalue
appends delimiter