My application uses custom NSURLProtocol
subclass. I need to substitute NSHTTPURLResponse
with my copy, modifying some of the headers fields. So, I create new NSHTTPURLResponse
instance, like that:
@implementation NSHTTPURLResponse (CocoaFix)
- (instancetype)HTTPResponseByRemovingValueForHeaderFields:(NSArray *)fields {
NSMutableDictionary *mutableHeaderFields = [self.allHeaderFields mutableCopy];
[mutableHeaderFields removeObjectsForKeys:fields];
return [[[self class] alloc] initWithURL:self.URL
statusCode:self.statusCode
HTTPVersion:@"HTTP/1.1" // What should I pass here?
headerFields:mutableHeaderFields];
}
@end
Problem occurs with HTTPVersion
parameter. I didn't find any way to obtain this value from original response.
Documentation says:
This is typically represented as "HTTP/1.1".
But providing hardcoded value not looks like a solution, that will work correctly all the time.
Please, help me with this one.