bugGNUstep - Bugs: bug #35673, Add new NSHTTPURLResponse...

Group
 
 

bug #35673: Add new NSHTTPURLResponse initializer method

Submitter:  Jens Alfke <snej>
Submitted:  Wed 29 Feb 2012 08:30:50 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Change Request Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  In Test
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 01 Mar 2012 07:41:34 PM UTC, comment #1: 

I implemented a version of that 10.7 method.
Hope it behaves as it should.

Richard Frith-Macdonald <CaS>
Group Member
Wed 29 Feb 2012 08:30:50 PM UTC, original submission:  

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

Jens Alfke <snej>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by snej (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-03-01 CaS StatusNone Fixed
        Open/ClosedOpen In Test

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code