react-native-static-server icon indicating copy to clipboard operation
react-native-static-server copied to clipboard

Ability to override Content-Type header for responses

Open benpham2509 opened this issue 3 years ago • 0 comments

Description

GCDWebServer provided the method that allows overriding the MIME types but react-native-static-server didn’t expose that capability, I added the optional mimeTypeOverrides argument to give the ability to override response’s Content-Type header.

Motivation and Context

When I tried to use this to set up our local server, it failed to set the correct Content-Type header for responses returning XML files. It sets application/octet-stream instead of application/xml as XMLHttpRequest expects. The root cause is that GCDWebServer sets the response’s Content-Type header to application/octet-stream for all file types, except for a few well-known ones such as HTML or CSS. Therefore, I implemented a simple change as described above to set the correct Content-Type header for responses.

benpham2509 avatar Aug 18 '22 13:08 benpham2509