@@ -28,53 +28,53 @@ #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" const char * -of_http_request_method_to_string(of_http_request_method_t method) +OFHTTPRequestMethodName(OFHTTPRequestMethod method) { switch (method) { - case OF_HTTP_REQUEST_METHOD_OPTIONS: + case OFHTTPRequestMethodOptions: return "OPTIONS"; - case OF_HTTP_REQUEST_METHOD_GET: + case OFHTTPRequestMethodGet: return "GET"; - case OF_HTTP_REQUEST_METHOD_HEAD: + case OFHTTPRequestMethodHead: return "HEAD"; - case OF_HTTP_REQUEST_METHOD_POST: + case OFHTTPRequestMethodPost: return "POST"; - case OF_HTTP_REQUEST_METHOD_PUT: + case OFHTTPRequestMethodPut: return "PUT"; - case OF_HTTP_REQUEST_METHOD_DELETE: + case OFHTTPRequestMethodDelete: return "DELETE"; - case OF_HTTP_REQUEST_METHOD_TRACE: + case OFHTTPRequestMethodTrace: return "TRACE"; - case OF_HTTP_REQUEST_METHOD_CONNECT: + case OFHTTPRequestMethodConnect: return "CONNECT"; } return NULL; } -of_http_request_method_t -of_http_request_method_from_string(OFString *string) +OFHTTPRequestMethod +OFHTTPRequestMethodParseName(OFString *string) { if ([string isEqual: @"OPTIONS"]) - return OF_HTTP_REQUEST_METHOD_OPTIONS; + return OFHTTPRequestMethodOptions; if ([string isEqual: @"GET"]) - return OF_HTTP_REQUEST_METHOD_GET; + return OFHTTPRequestMethodGet; if ([string isEqual: @"HEAD"]) - return OF_HTTP_REQUEST_METHOD_HEAD; + return OFHTTPRequestMethodHead; if ([string isEqual: @"POST"]) - return OF_HTTP_REQUEST_METHOD_POST; + return OFHTTPRequestMethodPost; if ([string isEqual: @"PUT"]) - return OF_HTTP_REQUEST_METHOD_PUT; + return OFHTTPRequestMethodPut; if ([string isEqual: @"DELETE"]) - return OF_HTTP_REQUEST_METHOD_DELETE; + return OFHTTPRequestMethodDelete; if ([string isEqual: @"TRACE"]) - return OF_HTTP_REQUEST_METHOD_TRACE; + return OFHTTPRequestMethodTrace; if ([string isEqual: @"CONNECT"]) - return OF_HTTP_REQUEST_METHOD_CONNECT; + return OFHTTPRequestMethodConnect; @throw [OFInvalidArgumentException exception]; } @implementation OFHTTPRequest @@ -92,11 +92,11 @@ - (instancetype)init { self = [super init]; - _method = OF_HTTP_REQUEST_METHOD_GET; + _method = OFHTTPRequestMethodGet; _protocolVersion.major = 1; _protocolVersion.minor = 1; return self; } @@ -121,19 +121,19 @@ [_headers release]; [super dealloc]; } -- (void)setRemoteAddress: (const of_socket_address_t *)remoteAddress +- (void)setRemoteAddress: (const OFSocketAddress *)remoteAddress { _hasRemoteAddress = (remoteAddress != NULL); if (_hasRemoteAddress) _remoteAddress = *remoteAddress; } -- (const of_socket_address_t *)remoteAddress +- (const OFSocketAddress *)remoteAddress { if (_hasRemoteAddress) return &_remoteAddress; return NULL; @@ -175,36 +175,36 @@ ![request->_URL isEqual: _URL] || ![request->_headers isEqual: _headers]) return false; if (request.remoteAddress != self.remoteAddress && - !of_socket_address_equal(request.remoteAddress, self.remoteAddress)) + !OFSocketAddressEqual(request.remoteAddress, self.remoteAddress)) return false; return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD(hash, _method); - OF_HASH_ADD(hash, _protocolVersion.major); - OF_HASH_ADD(hash, _protocolVersion.minor); - OF_HASH_ADD_HASH(hash, _URL.hash); - OF_HASH_ADD_HASH(hash, _headers.hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAdd(&hash, _method); + OFHashAdd(&hash, _protocolVersion.major); + OFHashAdd(&hash, _protocolVersion.minor); + OFHashAddHash(&hash, _URL.hash); + OFHashAddHash(&hash, _headers.hash); if (_hasRemoteAddress) - OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_remoteAddress)); + OFHashAddHash(&hash, OFSocketAddressHash(&_remoteAddress)); - OF_HASH_FINALIZE(hash); + OFHashFinalize(&hash); return hash; } -- (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion +- (void)setProtocolVersion: (OFHTTPRequestProtocolVersion)protocolVersion { if (protocolVersion.major != 1 || protocolVersion.minor > 1) @throw [OFUnsupportedVersionException exceptionWithVersion: [OFString stringWithFormat: @"%hhu.%hhu", protocolVersion.major, @@ -211,21 +211,21 @@ protocolVersion.minor]]; _protocolVersion = protocolVersion; } -- (of_http_request_protocol_version_t)protocolVersion +- (OFHTTPRequestProtocolVersion)protocolVersion { return _protocolVersion; } - (void)setProtocolVersionString: (OFString *)string { void *pool = objc_autoreleasePoolPush(); OFArray *components = [string componentsSeparatedByString: @"."]; unsigned long long major, minor; - of_http_request_protocol_version_t protocolVersion; + OFHTTPRequestProtocolVersion protocolVersion; if (components.count != 2) @throw [OFInvalidFormatException exception]; major = [components.firstObject unsignedLongLongValue]; @@ -250,20 +250,19 @@ } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); - const char *method = of_http_request_method_to_string(_method); + const char *method = OFHTTPRequestMethodName(_method); OFString *indentedHeaders, *remoteAddress, *ret; indentedHeaders = [_headers.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; if (_hasRemoteAddress) - remoteAddress = - of_socket_address_ip_string(&_remoteAddress, NULL); + remoteAddress = OFSocketAddressString(&_remoteAddress); else remoteAddress = nil; ret = [[OFString alloc] initWithFormat: @"<%@:\n\tURL = %@\n"