︙ | | |
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
-
+
|
OFTimer *_timer;
enum {
AWAITING_PROLOG,
PARSING_HEADERS,
SEND_RESPONSE
} _state;
uint8_t _HTTPMinorVersion;
of_http_request_method_t _method;
OFHTTPRequestMethod _method;
OFString *_host, *_path;
uint16_t _port;
OFMutableDictionary *_headers;
size_t _contentLength;
OFStream *_requestBody;
}
|
︙ | | |
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
-
+
|
void *pool = objc_autoreleasePoolPush();
OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers;
OFEnumerator *keyEnumerator, *valueEnumerator;
OFString *key, *value;
[_socket writeFormat: @"HTTP/%@ %hd %@\r\n",
self.protocolVersionString, _statusCode,
of_http_status_code_to_string(_statusCode)];
OFHTTPStatusCodeString(_statusCode)];
headers = [[_headers mutableCopy] autorelease];
if ([headers objectForKey: @"Date"] == nil) {
OFString *date = [[OFDate date]
dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"];
[headers setObject: date forKey: @"Date"];
|
︙ | | |
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
-
+
|
pos = [line rangeOfString: @" "].location;
if (pos == OFNotFound)
return [self sendErrorAndClose: 400];
method = [line substringToIndex: pos];
@try {
_method = of_http_request_method_from_string(method);
_method = OFHTTPRequestMethodParseName(method);
} @catch (OFInvalidArgumentException *e) {
return [self sendErrorAndClose: 405];
}
@try {
OFRange range = OFRangeMake(pos + 1, line.length - pos - 10);
|
︙ | | |
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
|
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
-
+
-
|
{
OFString *date = [[OFDate date]
dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"];
[_socket writeFormat: @"HTTP/1.1 %hd %@\r\n"
@"Date: %@\r\n"
@"Server: %@\r\n"
@"\r\n",
statusCode,
statusCode, OFHTTPStatusCodeString(statusCode),
of_http_status_code_to_string(statusCode),
date, _server.name];
return false;
}
- (void)createResponse
{
void *pool = objc_autoreleasePoolPush();
|
︙ | | |
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
|
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
-
+
|
URL.URLEncodedPath = _path;
[URL makeImmutable];
request = [OFHTTPRequest requestWithURL: URL];
request.method = _method;
request.protocolVersion =
(of_http_request_protocol_version_t){ 1, _HTTPMinorVersion };
(OFHTTPRequestProtocolVersion){ 1, _HTTPMinorVersion };
request.headers = _headers;
request.remoteAddress = _socket.remoteAddress;
response = [[[OFHTTPServerResponse alloc]
initWithSocket: _socket
server: _server
request: request] autorelease];
|
︙ | | |