@@ -69,16 +69,16 @@
[_response release];
[super dealloc];
}
-- (OFData *)stream: (OF_KINDOF(OFStream *))stream
+- (OFData *)stream: (OFStream *)stream
didWriteData: (OFData *)data
bytesWritten: (size_t)bytesWritten
exception: (id)exception
{
- if (exception != nil || [_file isAtEndOfStream])
+ if (exception != nil || _file.atEndOfStream)
return nil;
return readData(_file);
}
@end
@@ -93,23 +93,23 @@
- (void)parseConfig: (OFXMLElement *)config
{
OFMutableDictionary OF_GENERIC(OFString *, OFString *) *MIMETypes;
- _root = [[[config elementForName: @"root"] stringValue] copy];
+ _root = [[config elementForName: @"root"].stringValue copy];
if (_root == nil) {
[of_stderr writeString:
@"Error parsing config: No element!"];
[OFApplication terminateWithStatus: 1];
}
MIMETypes = [OFMutableDictionary dictionary];
for (OFXMLElement *MIMEType in [config elementsForName: @"mime-type"]) {
OFString *extension =
- [[MIMEType attributeForName: @"extension"] stringValue];
+ [MIMEType attributeForName: @"extension"].stringValue;
OFString *type =
- [[MIMEType attributeForName: @"type"] stringValue];
+ [MIMEType attributeForName: @"type"].stringValue;
if (extension == nil) {
[of_stderr writeString:
@"Error parsing config: "
@" has no extension attribute!"];
@@ -131,20 +131,20 @@
- (bool)handleRequest: (OFHTTPRequest *)request
requestBody: (OFStream *)requestBody
response: (OFHTTPResponse *)response
{
- OFURL *URL = [[request URL] URLByStandardizingPath];
- OFString *path = [URL path];
+ OFURL *URL = request.URL.URLByStandardizingPath;
+ OFString *path = URL.path;
OFMutableDictionary *headers = [OFMutableDictionary dictionary];
OFFileManager *fileManager;
bool firstComponent = true;
OFString *MIMEType;
StaticModule_FileSender *fileSender;
- for (OFString *component in [URL pathComponents]) {
- if (firstComponent && [component length] != 0)
+ for (OFString *component in URL.pathComponents) {
+ if (firstComponent && component.length != 0)
return false;
if ([component isEqual: @"."] || [component isEqual: @".."])
return false;
@@ -160,15 +160,15 @@
fileManager = [OFFileManager defaultManager];
if ([fileManager directoryExistsAtPath: path])
path = [path stringByAppendingPathComponent: @"index.html"];
if (![fileManager fileExistsAtPath: path]) {
- [response setStatusCode: 404];
+ response.statusCode = 404;
return false;
}
- MIMEType = [_MIMETypes objectForKey: [path pathExtension]];
+ MIMEType = [_MIMETypes objectForKey: path.pathExtension];
if (MIMEType == nil)
MIMEType = [_MIMETypes objectForKey: @""];
if (MIMEType != nil)
[headers setObject: MIMEType
@@ -177,13 +177,13 @@
fileSender = [[[StaticModule_FileSender alloc] init] autorelease];
fileSender->_file = [[OFFile alloc] initWithPath: path
mode: @"r"];
fileSender->_response = [response retain];
- [response setStatusCode: 200];
- [response setHeaders: headers];
- [response setDelegate: fileSender];
+ response.statusCode = 200;
+ response.headers = headers;
+ response.delegate = fileSender;
[response asyncWriteData: readData(fileSender->_file)];
return true;
}
@end