mirror of
https://github.com/swisspol/GCDWebServer.git
synced 2026-05-31 00:00:10 +08:00
Improved handling of symbolic links in -addGETHandlerForBasePath:directoryPath:indexFilename:cacheAge:allowRangeRequests:
This commit is contained in:
@@ -882,17 +882,18 @@ static inline NSString* _EncodeBase64(NSString* string) {
|
|||||||
|
|
||||||
GCDWebServerResponse* response = nil;
|
GCDWebServerResponse* response = nil;
|
||||||
NSString* filePath = [directoryPath stringByAppendingPathComponent:[request.path substringFromIndex:basePath.length]];
|
NSString* filePath = [directoryPath stringByAppendingPathComponent:[request.path substringFromIndex:basePath.length]];
|
||||||
BOOL isDirectory;
|
NSString* fileType = [[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:NULL] fileType];
|
||||||
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:&isDirectory]) {
|
if (fileType) {
|
||||||
if (isDirectory) {
|
if ([fileType isEqualToString:NSFileTypeDirectory]) {
|
||||||
if (indexFilename) {
|
if (indexFilename) {
|
||||||
NSString* indexPath = [filePath stringByAppendingPathComponent:indexFilename];
|
NSString* indexPath = [filePath stringByAppendingPathComponent:indexFilename];
|
||||||
if ([[NSFileManager defaultManager] fileExistsAtPath:indexPath isDirectory:&isDirectory] && !isDirectory) {
|
NSString* indexType = [[[NSFileManager defaultManager] attributesOfItemAtPath:indexPath error:NULL] fileType];
|
||||||
|
if ([indexType isEqualToString:NSFileTypeRegular]) {
|
||||||
return [GCDWebServerFileResponse responseWithFile:indexPath];
|
return [GCDWebServerFileResponse responseWithFile:indexPath];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response = [server _responseWithContentsOfDirectory:filePath];
|
response = [server _responseWithContentsOfDirectory:filePath];
|
||||||
} else {
|
} else if ([fileType isEqualToString:NSFileTypeRegular]) {
|
||||||
if (allowRangeRequests) {
|
if (allowRangeRequests) {
|
||||||
response = [GCDWebServerFileResponse responseWithFile:filePath byteRange:request.byteRange];
|
response = [GCDWebServerFileResponse responseWithFile:filePath byteRange:request.byteRange];
|
||||||
[response setValue:@"bytes" forAdditionalHeader:@"Accept-Ranges"];
|
[response setValue:@"bytes" forAdditionalHeader:@"Accept-Ranges"];
|
||||||
|
|||||||
Reference in New Issue
Block a user