Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
S
server
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Commons Host
server
Commits
a043fca5
Verified
Commit
a043fca5
authored
Dec 27, 2018
by
Sebastiaan Deckers
🐑
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: support unknown file types by omitting content-type header
parent
6f32c747
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
src/helpers/buildHeaders.js
src/helpers/buildHeaders.js
+5
-3
test/fixtures/unknown-file-type/file.unknown
test/fixtures/unknown-file-type/file.unknown
+1
-0
test/unknown-type.js
test/unknown-type.js
+22
-0
No files found.
src/helpers/buildHeaders.js
View file @
a043fca5
...
...
@@ -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
...
...
test/fixtures/unknown-file-type/file.unknown
0 → 100644
View file @
a043fca5
Stuff
\ No newline at end of file
test/unknown-type.js
0 → 100644
View file @
a043fca5
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
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment