I would like to append text to the default user-agent header in an NSURLConnection
. I know how to change the user-agent of the NSURLConnection, but I don't see how to get the default user-agent. I tried the following:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
NSString *userAgent = [request valueForHTTPHeaderField:@"User-Agent"];
userAgent = [userAgent stringByAppendingString:extraUserAgentInfo];
[request addValue:userAgent forHTTPHeaderField:@"User-Agent"];
This does not work because userAgent is coming back nil
from the valueForHTTPHeaderField:
call.