Is there any way to add HTTP header to NSURLRequest object? I used to add them in NSMutableURLRequest using:
[request addValue:@"PC" forHTTPHeaderField:@"machineName"]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think you can modify the HTTP Headers of a
NSURLRequest. I think you’re trying to modify aNSURLRequestobject that you didn’t initialize?You could create a
mutableCopyof your request and then set the header fields with the following method:After that you can
copythe mutable request back onto yourNSURLRequestvariable.EDIT: Added example below