Differences From Artifact [5da55a3a8f]:
- File src/OFHTTPServer.m — part of check-in [90de201b43] at 2013-09-29 19:44:03 on branch trunk — Get rid of a warning on 32-bit systems with Clang. (user: js, size: 15396) [annotate] [blame] [check-ins using]
To Artifact [6a0ef70d6f]:
- File
src/OFHTTPServer.m
— part of check-in
[fa6496efc7]
at
2013-12-05 17:48:11
on branch trunk
— Make coding style consistent.
A file documenting the coding style will be written soon. This will
hopefully prevent conflicts in the future, such as whether static
functions are written in camelCase or_with_underscores, like was the
case here. (user: js, size: 15385) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
50 51 52 53 54 55 56 | @interface OFHTTPServer (OF_PRIVATE_CATEGORY) - (bool)OF_socket: (OFTCPSocket*)socket didAcceptSocket: (OFTCPSocket*)clientSocket exception: (OFException*)exception; @end static const char* | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
@interface OFHTTPServer (OF_PRIVATE_CATEGORY)
- (bool)OF_socket: (OFTCPSocket*)socket
didAcceptSocket: (OFTCPSocket*)clientSocket
exception: (OFException*)exception;
@end
static const char*
statusCodeToString(short code)
{
switch (code) {
case 100:
return "Continue";
case 101:
return "Switching Protocols";
case 200:
|
| ︙ | ︙ | |||
139 140 141 142 143 144 145 | return "HTTP Version Not Supported"; default: return NULL; } } static OF_INLINE OFString* | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
return "HTTP Version Not Supported";
default:
return NULL;
}
}
static OF_INLINE OFString*
normalizedKey(OFString *key)
{
char *cString = strdup([key UTF8String]);
uint8_t *tmp = (uint8_t*)cString;
bool firstLetter = true;
if (cString == NULL)
@throw [OFOutOfMemoryException
|
| ︙ | ︙ | |||
213 214 215 216 217 218 219 | OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; [_socket writeFormat: @"HTTP/%@ %d %s\r\n" @"Server: %@\r\n" @"Date: %@\r\n", [self protocolVersionString], _statusCode, | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; [_socket writeFormat: @"HTTP/%@ %d %s\r\n" @"Server: %@\r\n" @"Date: %@\r\n", [self protocolVersionString], _statusCode, statusCodeToString(_statusCode), [_server name], date]; keyEnumerator = [_headers keyEnumerator]; valueEnumerator = [_headers objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (value = [valueEnumerator nextObject]) != nil) if (![key isEqual: @"Server"] && ![key isEqual: @"Date"]) |
| ︙ | ︙ | |||
477 478 479 480 481 482 483 | if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; key = [line substringWithRange: of_range(0, pos)]; value = [line substringWithRange: of_range(pos + 1, [line length] - pos - 1)]; | | | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
if (pos == OF_NOT_FOUND)
return [self sendErrorAndClose: 400];
key = [line substringWithRange: of_range(0, pos)];
value = [line substringWithRange:
of_range(pos + 1, [line length] - pos - 1)];
key = normalizedKey([key stringByDeletingTrailingWhitespaces]);
value = [value stringByDeletingLeadingWhitespaces];
[_headers setObject: value
forKey: key];
if ([key isEqual: @"Host"]) {
pos = [value
|
| ︙ | ︙ | |||
551 552 553 554 555 556 557 | OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; [_socket writeFormat: @"HTTP/1.1 %d %s\r\n" @"Date: %@\r\n" @"Server: %@\r\n" @"\r\n", | | | 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; [_socket writeFormat: @"HTTP/1.1 %d %s\r\n" @"Date: %@\r\n" @"Server: %@\r\n" @"\r\n", statusCode, statusCodeToString(statusCode), date, [_server name]]; [_socket close]; return false; } - (void)createResponse |
| ︙ | ︙ |