@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2021 Jonathan Schleifer + * Copyright (c) 2008-2022 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -78,44 +78,36 @@ } @implementation OFHTTPRequest @synthesize URL = _URL, method = _method, headers = _headers; -+ (instancetype)request -{ - return [[[self alloc] init] autorelease]; -} - + (instancetype)requestWithURL: (OFURL *)URL { return [[[self alloc] initWithURL: URL] autorelease]; } -- (instancetype)init +- (instancetype)initWithURL: (OFURL *)URL { self = [super init]; - _method = OFHTTPRequestMethodGet; - _protocolVersion.major = 1; - _protocolVersion.minor = 1; - - return self; -} - -- (instancetype)initWithURL: (OFURL *)URL -{ - self = [self init]; - @try { _URL = [URL copy]; + _method = OFHTTPRequestMethodGet; + _protocolVersion.major = 1; + _protocolVersion.minor = 1; } @catch (id e) { [self release]; @throw e; } return self; } + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} - (void)dealloc { [_URL release]; [_headers release]; @@ -139,16 +131,15 @@ return NULL; } - (id)copy { - OFHTTPRequest *copy = [[OFHTTPRequest alloc] init]; + OFHTTPRequest *copy = [[OFHTTPRequest alloc] initWithURL: _URL]; @try { copy->_method = _method; copy->_protocolVersion = _protocolVersion; - copy.URL = _URL; copy.headers = _headers; copy.remoteAddress = self.remoteAddress; } @catch (id e) { [copy release]; @throw e;