Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
732696e8
Commit
732696e8
authored
Dec 06, 2017
by
Patryk
Committed by
Tim Neutkens
Dec 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a charset to the default Content-Type (#3333)
parent
e2bcb039
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
render.js
server/render.js
+1
-1
custom-encoding.js
test/integration/basic/pages/custom-encoding.js
+1
-1
rendering.js
test/integration/basic/test/rendering.js
+2
-2
No files found.
server/render.js
View file @
732696e8
...
@@ -186,7 +186,7 @@ export function sendHTML (req, res, html, method, { dev }) {
...
@@ -186,7 +186,7 @@ export function sendHTML (req, res, html, method, { dev }) {
res
.
setHeader
(
'ETag'
,
etag
)
res
.
setHeader
(
'ETag'
,
etag
)
if
(
!
res
.
getHeader
(
'Content-Type'
))
{
if
(
!
res
.
getHeader
(
'Content-Type'
))
{
res
.
setHeader
(
'Content-Type'
,
'text/html'
)
res
.
setHeader
(
'Content-Type'
,
'text/html
; charset=utf-8
'
)
}
}
res
.
setHeader
(
'Content-Length'
,
Buffer
.
byteLength
(
html
))
res
.
setHeader
(
'Content-Length'
,
Buffer
.
byteLength
(
html
))
res
.
end
(
method
===
'HEAD'
?
null
:
html
)
res
.
end
(
method
===
'HEAD'
?
null
:
html
)
...
...
test/integration/basic/pages/custom-encoding.js
View file @
732696e8
...
@@ -2,7 +2,7 @@ import React from 'react'
...
@@ -2,7 +2,7 @@ import React from 'react'
export
default
class
extends
React
.
Component
{
export
default
class
extends
React
.
Component
{
static
async
getInitialProps
({
res
})
{
static
async
getInitialProps
({
res
})
{
if
(
res
)
{
if
(
res
)
{
res
.
setHeader
(
'Content-Type'
,
'text/html; charset=
utf-8
'
)
res
.
setHeader
(
'Content-Type'
,
'text/html; charset=
iso-8859-2
'
)
}
}
return
{}
return
{}
}
}
...
...
test/integration/basic/test/rendering.js
View file @
732696e8
...
@@ -71,12 +71,12 @@ export default function ({ app }, suiteName, render, fetch) {
...
@@ -71,12 +71,12 @@ export default function ({ app }, suiteName, render, fetch) {
test
(
'default Content-Type'
,
async
()
=>
{
test
(
'default Content-Type'
,
async
()
=>
{
const
res
=
await
fetch
(
'/stateless'
)
const
res
=
await
fetch
(
'/stateless'
)
expect
(
res
.
headers
.
get
(
'Content-Type'
)).
toMatch
(
'text/html'
)
expect
(
res
.
headers
.
get
(
'Content-Type'
)).
toMatch
(
'text/html
; charset=utf-8
'
)
})
})
test
(
'setting Content-Type in getInitialProps'
,
async
()
=>
{
test
(
'setting Content-Type in getInitialProps'
,
async
()
=>
{
const
res
=
await
fetch
(
'/custom-encoding'
)
const
res
=
await
fetch
(
'/custom-encoding'
)
expect
(
res
.
headers
.
get
(
'Content-Type'
)).
toMatch
(
'text/html; charset=
utf-8
'
)
expect
(
res
.
headers
.
get
(
'Content-Type'
)).
toMatch
(
'text/html; charset=
iso-8859-2
'
)
})
})
test
(
'allows to import .json files'
,
async
()
=>
{
test
(
'allows to import .json files'
,
async
()
=>
{
...
...
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