From ee9febce6e72a35fa2b69f67fd7d816dbd8128a2 Mon Sep 17 00:00:00 2001 From: Jeyaram Jeyaraj Date: Thu, 3 Dec 2015 12:07:18 -0800 Subject: [PATCH] Implementing the missing mainDocumentUrl property for NSMutableURL. --- Frameworks/Foundation/NSMutableURLRequest.mm | 21 +++++------- include/Foundation/NSMutableURLRequest.h | 36 +++++++++++--------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Frameworks/Foundation/NSMutableURLRequest.mm b/Frameworks/Foundation/NSMutableURLRequest.mm index 8d752c519b..8238622c6e 100644 --- a/Frameworks/Foundation/NSMutableURLRequest.mm +++ b/Frameworks/Foundation/NSMutableURLRequest.mm @@ -23,16 +23,6 @@ @implementation NSMutableURLRequest -- (id)initWithURL:(id)url { - _url = [url absoluteURL]; - _timeoutInterval = 30.0; - _headerFields = [NSMutableDictionary new]; - _method = @"GET"; - _shouldHandleCookies = true; - - return self; -} - /** @Status Interoperable */ @@ -130,17 +120,22 @@ - (void)setHTTPShouldUsePipelining:(BOOL)shouldPipeline { } - (id)copyWithZone:(NSZone*)zone { - NSURLRequest* ret = [[NSMutableURLRequest alloc] initWithURL:(id)_url - cachePolicy:NSURLRequestUseProtocolCachePolicy - timeoutInterval:30.0]; /* [BUG: Make it copy all properties] */ + NSMutableURLRequest* ret = [[NSMutableURLRequest alloc] initWithURL:(id)_url + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:30.0]; /* [BUG: Make it copy all properties] */ ret->_headerFields = [_headerFields mutableCopy]; ret->_method.attach([_method copy]); ret->_body.attach([_body copy]); ret->_shouldHandleCookies = _shouldHandleCookies; ret->_cachePolicy = _cachePolicy; ret->_bodyStream = _bodyStream; + ret.mainDocumentURL = _mainDocumentURL; return ret; } +- (void)dealloc { + [_mainDocumentURL release]; + [super dealloc]; +} @end diff --git a/include/Foundation/NSMutableURLRequest.h b/include/Foundation/NSMutableURLRequest.h index 1cdbf5b920..02176ce8e1 100644 --- a/include/Foundation/NSMutableURLRequest.h +++ b/include/Foundation/NSMutableURLRequest.h @@ -1,33 +1,37 @@ /* Copyright (c) 2006-2007 Christopher J. W. Lloyd -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #import FOUNDATION_EXPORT_CLASS @interface NSMutableURLRequest : NSURLRequest --(void)setURL:(NSURL *)value; --(void)setCachePolicy:(NSURLRequestCachePolicy)value; --(void)setTimeoutInterval:(NSTimeInterval)value; +@property (copy) NSURL* mainDocumentURL; --(void)setHTTPMethod:(NSString *)value; +- (void)setURL:(NSURL*)value; +- (void)setCachePolicy:(NSURLRequestCachePolicy)value; +- (void)setTimeoutInterval:(NSTimeInterval)value; --(void)setHTTPBody:(NSData *)value; --(void)setHTTPBodyStream:(NSInputStream *)value; +- (void)setHTTPMethod:(NSString*)value; --(void)setAllHTTPHeaderFields:(NSDictionary *)allValues; --(void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; --(void)addValue:(NSString *)value forHTTPHeaderField:(NSString *)field; +- (void)setHTTPBody:(NSData*)value; +- (void)setHTTPBodyStream:(NSInputStream*)value; --(void)setHTTPShouldHandleCookies:(BOOL)value; +- (void)setAllHTTPHeaderFields:(NSDictionary*)allValues; +- (void)setValue:(NSString*)value forHTTPHeaderField:(NSString*)field; +- (void)addValue:(NSString*)value forHTTPHeaderField:(NSString*)field; --(void)setMainDocumentURL:(NSURL *)value; --(void)setHTTPShouldUsePipelining:(BOOL)shouldUsePipelining; - --(void)setAllowsInvalidSSLCertificate:(BOOL)allowsInvalidCertificiate; +- (void)setHTTPShouldHandleCookies:(BOOL)value; +- (void)setHTTPShouldUsePipelining:(BOOL)shouldUsePipelining; @end