Commit a043fca5 authored by Sebastiaan Deckers's avatar Sebastiaan Deckers 馃悜

fix: support unknown file types by omitting content-type header

parent 6f32c747
......@@ -20,9 +20,11 @@ module.exports.buildHeaders = function buildHeaders (
let resolved = sourceFile
const headers = {}
const type = mime.getType(sourceFile.absolute)
if (type !== null) {
headers['content-type'] = type.startsWith('text/')
? `${type}; charset=utf-8`
: type
}
const isImmutable = checkImmutable(sourceFile.absolute, immutablePatterns)
headers['cache-control'] = isImmutable
......
Stuff
\ No newline at end of file
const test = require('blue-tape')
const { Master } = require('..')
const { join } = require('path')
const { h1 } = require('./helpers/receive')
let master
test('start server', async (t) => {
const cwd = join(__dirname, 'fixtures/unknown-file-type')
const options = {}
master = new Master({ cwd, options })
await master.listen()
})
test('Unknown file type', async (t) => {
const url = 'https://localhost:8443/file.unknown'
const response = await h1(url)
t.is(response.status, 200)
t.is(response.headers['content-type'], undefined)
t.is(await response.text(), 'Stuff')
})
test('stop server', async (t) => master.close())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment