Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
{
NSUInteger offset;
NSData *data;
NSString *contentType;
}

- (id)initWithData:(NSData *)data;
- (id)initWithData:(NSData *)dataParam;
- (id)initWithData:(NSData *)dataParam contentType:(NSString *)contentTypeParam;

@end
20 changes: 19 additions & 1 deletion LauncherOSX/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,34 @@

@implementation HTTPDataResponse

- (NSDictionary *)httpHeaders {

if(contentType) {
return [NSDictionary dictionaryWithObject:contentType forKey:@"Content-Type"];
}

return [NSDictionary new];
}


- (id)initWithData:(NSData *)dataParam
{
if((self = [super init]))
return [self initWithData:dataParam contentType:nil];
}

- (id)initWithData:(NSData *)dataParam contentType:(NSString *)contentTypeParam
{
if((self = [super init]))
{
HTTPLogTrace();

offset = 0;
data = dataParam;
contentType = contentTypeParam;
}

return self;

}

- (void)dealloc
Expand Down
9 changes: 9 additions & 0 deletions LauncherOSX/CocoaHTTPServer/Core/Responses/HTTPFileResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@

@implementation HTTPFileResponse

- (NSDictionary *)httpHeaders {
//HTTPLogTrace();
if ([[[filePath pathExtension] lowercaseString] isEqualToString:@"svg"]) {
return [NSDictionary dictionaryWithObject:@"image/svg+xml" forKey:@"Content-Type"];
}
return [NSDictionary new];
}


- (id)initWithFilePath:(NSString *)fpath forConnection:(HTTPConnection *)parent
{
if((self = [super init]))
Expand Down
24 changes: 23 additions & 1 deletion LauncherOSX/PackageResourceServer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ @implementation PackageResourceConnection
@synchronized ([PackageResourceServer resourceLock]) {
RDPackageResource *resource = [m_package resourceAtRelativePath:path];

NSString* ext = [[path pathExtension] lowercaseString];
NSString* contentType = nil;

if([ext isEqualToString:@"svg"]) {
contentType = @"image/svg+xml";
}


if (resource == nil) {
NSLog(@"No resource found! (%@)", path);
}
Expand All @@ -61,7 +69,7 @@ @implementation PackageResourceConnection
NSData *data = resource.data;

if (data != nil) {
return [[HTTPDataResponse alloc] initWithData:data];
return [[HTTPDataResponse alloc] initWithData:data contentType:contentType];
}
}
else {
Expand All @@ -82,6 +90,20 @@ + (void)setPackage:(LOXPackage *)package {

@implementation PackageResourceResponse

- (NSDictionary *)httpHeaders {

if(m_resource.relativePath) {

NSString* ext = [[m_resource.relativePath pathExtension] lowercaseString];

if([ext isEqualToString:@"svg"]) {
return [NSDictionary dictionaryWithObject:@"image/svg+xml" forKey:@"Content-Type"];
}

}

return [NSDictionary new];
}

- (UInt64)contentLength {
return m_resource.bytesCount;
Expand Down
1 change: 1 addition & 0 deletions LauncherOSX/RDPackageResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@interface RDPackageResource : NSObject {
@private LOXPackage *m_package;
@private NSData *m_data;

}

//@property (nonatomic, readonly) ePub3::ByteStream* byteStream;
Expand Down