1

I am implementing a simple static webserver using GCDWebserver, problem is my jpeg file names do not have a file extension.

This is confusing my clients I see there is a kGCDWebServerDefaultMimeType in GCDWebServerPrivate.h

#define kGCDWebServerDefaultMimeType @"application/octet-stream"

What would be the simplest way for me to change this to @"image/jpeg" without changing the library header ? I am using Cocoapods pod "GCDWebServer", "~> 3.0"

Currently the only code I have is

[_webServer addGETHandlerForBasePath:@"/" directoryPath:mediaRoot indexFilename:nil cacheAge:3600 allowRangeRequests:YES];

[_webServer startWithPort:8080 bonjourName:nil];
Ryan Heitner
  • 13,119
  • 6
  • 77
  • 119

1 Answers1

0

Because you are using a high-level wrapper API, you can't customize the GCDWebServerResponse instances created internally e.g. to change their contentType property.

You would either need to patch the source code to change kGCDWebServerDefaultMimeType, or copy-paste the implementation of -addGETHandlerForBasePath:... and customize it to your needs by at the minimum changing the contentType property of the created GCDWebServerResponse instances to image/jpeg.

Pol
  • 3,848
  • 1
  • 38
  • 55