Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
b860be01
Commit
b860be01
authored
Feb 19, 2016
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #615 from 1lann/master
errors: Set missing Content-Type for plaintext error messages
parents
f7b5187b
5f2670fd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
1 deletion
+3
-1
caddy/setup/errors.go
caddy/setup/errors.go
+1
-1
middleware/errors/errors.go
middleware/errors/errors.go
+2
-0
No files found.
caddy/setup/errors.go
View file @
b860be01
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
"github.com/mholt/caddy/middleware/errors"
"github.com/mholt/caddy/middleware/errors"
)
)
// Errors configures a new
gzip
middleware instance.
// Errors configures a new
errors
middleware instance.
func
Errors
(
c
*
Controller
)
(
middleware
.
Middleware
,
error
)
{
func
Errors
(
c
*
Controller
)
(
middleware
.
Middleware
,
error
)
{
handler
,
err
:=
errorsParse
(
c
)
handler
,
err
:=
errorsParse
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
middleware/errors/errors.go
View file @
b860be01
...
@@ -34,6 +34,7 @@ func (h ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, er
...
@@ -34,6 +34,7 @@ func (h ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, er
if
h
.
Debug
{
if
h
.
Debug
{
// Write error to response instead of to log
// Write error to response instead of to log
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/plain; charset=utf-8"
)
w
.
WriteHeader
(
status
)
w
.
WriteHeader
(
status
)
fmt
.
Fprintln
(
w
,
errMsg
)
fmt
.
Fprintln
(
w
,
errMsg
)
return
0
,
err
// returning < 400 signals that a response has been written
return
0
,
err
// returning < 400 signals that a response has been written
...
@@ -124,6 +125,7 @@ func (h ErrorHandler) recovery(w http.ResponseWriter, r *http.Request) {
...
@@ -124,6 +125,7 @@ func (h ErrorHandler) recovery(w http.ResponseWriter, r *http.Request) {
// Write error and stack trace to the response rather than to a log
// Write error and stack trace to the response rather than to a log
var
stackBuf
[
4096
]
byte
var
stackBuf
[
4096
]
byte
stack
:=
stackBuf
[
:
runtime
.
Stack
(
stackBuf
[
:
],
false
)]
stack
:=
stackBuf
[
:
runtime
.
Stack
(
stackBuf
[
:
],
false
)]
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/plain; charset=utf-8"
)
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
fmt
.
Fprintf
(
w
,
"%s
\n\n
%s"
,
panicMsg
,
stack
)
fmt
.
Fprintf
(
w
,
"%s
\n\n
%s"
,
panicMsg
,
stack
)
}
else
{
}
else
{
...
...
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