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:

addvalue

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.

setvalue

the new value header field. existing value field replaced new value.


setvalue replaces. addvalue appends delimiter


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -