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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #35673: Add new NSHTTPURLResponse initializer method

Submitted by:  Jens Alfke <snej>
Submitted on:  Wed 29 Feb 2012 08:30:50 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: Change RequestStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: In Test

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>
Project 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>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 01 Mar 2012 07:41:34 PM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1