-[NSMutableURLRequest setAllHTTPHeaderFields:] does not remove headers
| Originator: | heath.borders | ||
| Number: | rdar://11820519 | Date Originated: | 06-Jul-2012 02:22 PM |
| Status: | Open | Resolved: | |
| Product: | iPad SDK | Product Version: | Xcode 4.3.3 |
| Classification: | Serious Bug | Reproducible: | Always |
06-Jul-2012 02:22 PM Heath Borders: Summary: The documentation to -[NSMutableURLRequest setAllHTTPHeaderFields:] says: Replaces the receiver's header fields with the passed values. However, fields not present in the given NSDictionary are not removed from the NSMutableURLRequest. Steps to Reproduce: NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://apple.com"]]; [request addValue:@"bar" forHTTPHeaderField:@"foo"]; [request setAllHTTPHeaderFields:[NSDictionary dictionaryWithObject:@"bar2" forKey:@"foo2"]]; NSLog(@"%@", [request allHTTPHeaderFields]); Expected Results: foo2=bar2 Actual Results: foo=bar foo2=bar2 Regression: Notes: If this is expected behavior, then make it explicit in the documentation that it will only replace existing values rather than replacing headers. Replacing headers implies it replaces the entire dictionary.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!