I found that for some header fields ("User-Agent" is one of them), setting the header value to nil using
[request addValue:nil forHTTPHeaderField:@"User-Agent"];
doesnβt actually delete the header field, but sets it by default!
If you want to delete the content, just set the value to an empty string with
[request addValue:@"" forHTTPHeaderField:@"User-Agent"];
nburk source share