URL: <http://savannah.gnu.org/bugs/?35673>
Summary: Add new NSHTTPURLResponse initializer method Project: GNUstep Submitted by: snej Submitted on: Wed 29 Feb 2012 08:30:50 PM GMT Category: Base/Foundation Severity: 3 - Normal Item Group: Change Request Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any _______________________________________________________ Details: OS X 10.7 and iOS 5 add a public initializer method for NSHTTPURLResponse. Without this method it's not feasible for application code to create an instance of this class, since its properties aren't settable. This becomes a blocker for implementations of NSURLProtocol that want to implement HTTP-like protocols that return responses with headers and status codes. Index: Headers/Foundation/NSURLResponse.h =================================================================== --- Headers/Foundation/NSURLResponse.h (revision 34837) +++ Headers/Foundation/NSURLResponse.h (working copy) @@ -106,6 +106,11 @@ @interface NSHTTPURLResponse : NSURLResponse /** + * Initializes the receiver. + */ +- (id) initWithURL: (NSURL*) url statusCode: (NSInteger) statusCode HTTPVersion: (NSString*) HTTPVersion headerFields: (NSDictionary*) headerFields; + +/** * Returns a string representation of a status code. */ + (NSString *) localizedStringForStatusCode: (NSInteger)statusCode; Index: Source/NSURLResponse.m =================================================================== --- Source/NSURLResponse.m (revision 34837) +++ Source/NSURLResponse.m (working copy) @@ -324,6 +324,16 @@ @implementation NSHTTPURLResponse +-(id)initWithURL:(NSURL*) url statusCode:(NSInteger) statusCode + HTTPVersion:(NSString*) HTTPVersion headerFields:(NSDictionary*) headerFields { + self = [super initWithURL: url MIMEType: nil expectedContentLength: NSURLResponseUnknownLength textEncodingName: nil]; + if (self) { + this->statusCode = statusCode; + this->headers = [headerFields copy]; + } + return self; +} + + (NSString *) localizedStringForStatusCode: (NSInteger)statusCode { // FIXME ... put real responses in here _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?35673> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-gnustep mailing list Bug-gnustep@gnu.org https://lists.gnu.org/mailman/listinfo/bug-gnustep