Skip to content

Commit 88da920

Browse files
committed
Basic NSURLRequest initialization
1 parent 3890043 commit 88da920

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Foundation/NSURLRequest.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ public enum NSURLRequestNetworkServiceType : UInt {
164164
*/
165165
public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopying {
166166

167+
private var _URL : NSURL?
168+
private var _mainDocumentURL: NSURL?
169+
private var _httpHeaderFields: [String: String]?
170+
167171
public func copyWithZone(zone: NSZone) -> AnyObject {
168172
NSUnimplemented()
169173
}
@@ -180,6 +184,8 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
180184
NSUnimplemented()
181185
}
182186

187+
private override init() {}
188+
183189
/*!
184190
@method requestWithURL:
185191
@abstract Allocates and initializes an NSURLRequest with the given
@@ -219,14 +225,17 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
219225
@param URL The URL for the request.
220226
@result An initialized NSURLRequest.
221227
*/
222-
public convenience init(URL: NSURL) { NSUnimplemented() }
228+
public convenience init(URL: NSURL) {
229+
self.init()
230+
_URL = URL
231+
}
223232

224233
/*!
225234
@method URL
226235
@abstract Returns the URL of the receiver.
227236
@result The URL of the receiver.
228237
*/
229-
/*@NSCopying */public var URL: NSURL? { NSUnimplemented() }
238+
/*@NSCopying */public var URL: NSURL? { return _URL }
230239

231240
/*!
232241
@method mainDocumentURL
@@ -236,14 +245,14 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
236245
See setMainDocumentURL:
237246
@result The main document URL.
238247
*/
239-
/*@NSCopying*/ public var mainDocumentURL: NSURL? { NSUnimplemented() }
248+
/*@NSCopying*/ public var mainDocumentURL: NSURL? { return _mainDocumentURL }
240249

241250
/*!
242251
@method HTTPMethod
243252
@abstract Returns the HTTP request method of the receiver.
244253
@result the HTTP request method of the receiver.
245254
*/
246-
public var HTTPMethod: String? { get { NSUnimplemented() }}
255+
public var HTTPMethod: String? { get { return "GET" }}
247256

248257
/*!
249258
@method allHTTPHeaderFields
@@ -252,7 +261,7 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
252261
@result a dictionary containing all the HTTP header fields of the
253262
receiver.
254263
*/
255-
public var allHTTPHeaderFields: [String : String]? { NSUnimplemented() }
264+
public var allHTTPHeaderFields: [String : String]? { return _httpHeaderFields }
256265

257266
/*!
258267
@method valueForHTTPHeaderField:
@@ -264,7 +273,7 @@ public class NSURLRequest : NSObject, NSSecureCoding, NSCopying, NSMutableCopyin
264273
@result the value associated with the given header field, or nil if
265274
there is no value associated with the given header field.
266275
*/
267-
public func valueForHTTPHeaderField(field: String) -> String? { NSUnimplemented() }
276+
public func valueForHTTPHeaderField(field: String) -> String? { return _httpHeaderFields?[field.lowercaseString] }
268277

269278
}
270279

0 commit comments

Comments
 (0)