@@ -27,37 +27,37 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" -const char * -OFHTTPRequestMethodName(OFHTTPRequestMethod method) +OFString * +OFHTTPRequestMethodString(OFHTTPRequestMethod method) { switch (method) { case OFHTTPRequestMethodOptions: - return "OPTIONS"; - case OFHTTPRequestMethodGet: - return "GET"; - case OFHTTPRequestMethodHead: - return "HEAD"; - case OFHTTPRequestMethodPost: - return "POST"; - case OFHTTPRequestMethodPut: - return "PUT"; - case OFHTTPRequestMethodDelete: - return "DELETE"; - case OFHTTPRequestMethodTrace: - return "TRACE"; - case OFHTTPRequestMethodConnect: - return "CONNECT"; - } - - return NULL; + return @"OPTIONS"; + case OFHTTPRequestMethodGet: + return @"GET"; + case OFHTTPRequestMethodHead: + return @"HEAD"; + case OFHTTPRequestMethodPost: + return @"POST"; + case OFHTTPRequestMethodPut: + return @"PUT"; + case OFHTTPRequestMethodDelete: + return @"DELETE"; + case OFHTTPRequestMethodTrace: + return @"TRACE"; + case OFHTTPRequestMethodConnect: + return @"CONNECT"; + } + + return nil; } OFHTTPRequestMethod -OFHTTPRequestMethodParseName(OFString *string) +OFHTTPRequestMethodParseString(OFString *string) { if ([string isEqual: @"OPTIONS"]) return OFHTTPRequestMethodOptions; if ([string isEqual: @"GET"]) return OFHTTPRequestMethodGet; @@ -74,10 +74,24 @@ if ([string isEqual: @"CONNECT"]) return OFHTTPRequestMethodConnect; @throw [OFInvalidFormatException exception]; } + +/* Deprecated */ +const char * +OFHTTPRequestMethodName(OFHTTPRequestMethod method) +{ + return OFHTTPRequestMethodString(method).UTF8String; +} + +/* Deprecated */ +OFHTTPRequestMethod +OFHTTPRequestMethodParseName(OFString *string) +{ + return OFHTTPRequestMethodParseString(string); +} @implementation OFHTTPRequest @synthesize IRI = _IRI, method = _method, headers = _headers; + (instancetype)requestWithIRI: (OFIRI *)IRI @@ -241,11 +255,11 @@ } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); - const char *method = OFHTTPRequestMethodName(_method); + OFString *method = OFHTTPRequestMethodString(_method); OFString *indentedHeaders, *remoteAddress, *ret; indentedHeaders = [_headers.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; @@ -255,11 +269,11 @@ else remoteAddress = nil; ret = [[OFString alloc] initWithFormat: @"<%@:\n\tIRI = %@\n" - @"\tMethod = %s\n" + @"\tMethod = %@\n" @"\tHeaders = %@\n" @"\tRemote address = %@\n" @">", self.class, _IRI, method, indentedHeaders, remoteAddress];