NSMutableURLRequest modifying header fields
NSMutableURLRequest apparently changes case on header fields.
For example, setting:
[request addValue:myValue forHTTPHeaderField:@开发者_运维百科"FOOBAR"];
will change the header field to "Foobar".
Anybody know a way around this? I am working with a service that requires a case sensitive field to be passed.
Also, NSMutableURLRequest shouldn't really be making the decision for me.
NSMutableURLRequest
follows the RFC 2616 spec for HTTP/1.1 which says:
Field names are case-insensitive.
Or the documentation, which says:
In keeping with the HTTP RFC, HTTP header field names are case-insensitive.
So we can conclude that NSURLRequest
is really just standardizing capitalization of the header fields. How thoughtful of it. =)
Looks like you're out of luck.
Edit: "I am working with a service that requires a case sensitive field to be passed." Since the HTTP/1.1 protocol defines header field names to be case insensitive, this service is breaking the protocol. The internet is already full of examples on what happens when companies and services try to ignore the protocol for their own benefit. (Ex: ever tried to write a webpage that works in Firefox and IE6?) I'd avoid using this service if you could, or write to them and let them know what they're doing and why it's wrong.
精彩评论