@@ -45,16 +45,16 @@ * FIXME: Key normalization replaces headers like "DNT" with "Dnt". * FIXME: Errors are not reported to the user. */ @interface OFHTTPServer () -- (bool)OF_socket: (OFTCPSocket*)socket - didAcceptSocket: (OFTCPSocket*)clientSocket - exception: (OFException*)exception; +- (bool)OF_socket: (OFTCPSocket *)socket + didAcceptSocket: (OFTCPSocket *)clientSocket + exception: (OFException *)exception; @end -static const char* +static const char * statusCodeToString(short code) { switch (code) { case 100: return "Continue"; @@ -139,15 +139,15 @@ default: return NULL; } } -static OF_INLINE OFString* +static OF_INLINE OFString * normalizedKey(OFString *key) { char *cString = of_strdup([key UTF8String]); - unsigned char *tmp = (unsigned char*)cString; + unsigned char *tmp = (unsigned char *)cString; bool firstLetter = true; if (cString == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: strlen([key UTF8String])]; @@ -177,19 +177,19 @@ OFHTTPServer *_server; OFHTTPRequest *_request; bool _chunked, _headersSent; } -- initWithSocket: (OFTCPSocket*)socket - server: (OFHTTPServer*)server - request: (OFHTTPRequest*)request; +- initWithSocket: (OFTCPSocket *)socket + server: (OFHTTPServer *)server + request: (OFHTTPRequest *)request; @end @implementation OFHTTPServerResponse -- initWithSocket: (OFTCPSocket*)socket - server: (OFHTTPServer*)server - request: (OFHTTPRequest*)request +- initWithSocket: (OFTCPSocket *)socket + server: (OFHTTPServer *)server + request: (OFHTTPRequest *)request { self = [super init]; _statusCode = 500; _socket = [socket retain]; @@ -211,11 +211,11 @@ } - (void)OF_sendHeaders { void *pool = objc_autoreleasePoolPush(); - OFMutableDictionary OF_GENERIC(OFString*, OFString*) *headers; + OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers; OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; [_socket writeFormat: @"HTTP/%@ %d %s\r\n", [self protocolVersionString], _statusCode, @@ -252,11 +252,11 @@ isEqual: @"chunked"]; objc_autoreleasePoolPop(pool); } -- (void)lowlevelWriteBuffer: (const void*)buffer +- (void)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { void *pool; if (_socket == nil) @@ -336,28 +336,28 @@ OFMutableDictionary *_headers; size_t _contentLength; OFDataArray *_body; } -- initWithSocket: (OFTCPSocket*)socket - server: (OFHTTPServer*)server; -- (bool)socket: (OFTCPSocket*)socket - didReadLine: (OFString*)line - exception: (OFException*)exception; -- (bool)parseProlog: (OFString*)line; -- (bool)parseHeaders: (OFString*)line; -- (bool)socket: (OFTCPSocket*)socket - didReadIntoBuffer: (char*)buffer +- initWithSocket: (OFTCPSocket *)socket + server: (OFHTTPServer *)server; +- (bool)socket: (OFTCPSocket *)socket + didReadLine: (OFString *)line + exception: (OFException *)exception; +- (bool)parseProlog: (OFString *)line; +- (bool)parseHeaders: (OFString *)line; +- (bool)socket: (OFTCPSocket *)socket + didReadIntoBuffer: (char *)buffer length: (size_t)length - exception: (OFException*)exception; + exception: (OFException *)exception; - (bool)sendErrorAndClose: (short)statusCode; - (void)createResponse; @end @implementation OFHTTPServer_Connection -- initWithSocket: (OFTCPSocket*)socket - server: (OFHTTPServer*)server +- initWithSocket: (OFTCPSocket *)socket + server: (OFHTTPServer *)server { self = [super init]; @try { _socket = [socket retain]; @@ -391,13 +391,13 @@ [_body release]; [super dealloc]; } -- (bool)socket: (OFTCPSocket*)socket - didReadLine: (OFString*)line - exception: (OFException*)exception +- (bool)socket: (OFTCPSocket *)socket + didReadLine: (OFString *)line + exception: (OFException *)exception { if (line == nil || exception != nil) return false; @try { @@ -422,11 +422,11 @@ } OF_ENSURE(0); } -- (bool)parseProlog: (OFString*)line +- (bool)parseProlog: (OFString *)line { OFString *method; OFMutableString *path; size_t pos; @@ -481,11 +481,11 @@ _state = PARSING_HEADERS; return true; } -- (bool)parseHeaders: (OFString*)line +- (bool)parseHeaders: (OFString *)line { OFString *key, *value, *old; size_t pos; if ([line length] == 0) { @@ -569,14 +569,14 @@ } return true; } -- (bool)socket: (OFTCPSocket*)socket - didReadIntoBuffer: (char*)buffer +- (bool)socket: (OFTCPSocket *)socket + didReadIntoBuffer: (char *)buffer length: (size_t)length - exception: (OFException*)exception + exception: (OFException *)exception { if ([socket isAtEndOfStream] || exception != nil) return false; [_body addItems: buffer @@ -729,13 +729,13 @@ [_listeningSocket cancelAsyncRequests]; [_listeningSocket release]; _listeningSocket = nil; } -- (bool)OF_socket: (OFTCPSocket*)socket - didAcceptSocket: (OFTCPSocket*)clientSocket - exception: (OFException*)exception +- (bool)OF_socket: (OFTCPSocket *)socket + didAcceptSocket: (OFTCPSocket *)clientSocket + exception: (OFException *)exception { OFHTTPServer_Connection *connection; if (exception != nil) { if ([_delegate respondsToSelector: