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
5f2670fd
Commit
5f2670fd
authored
Feb 20, 2016
by
Jason Chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix missing Content-Type for certain errors
And corrected an error in a copy and pasted comment
parent
ecf913e5
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 @
5f2670fd
...
...
@@ -12,7 +12,7 @@ import (
"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
)
{
handler
,
err
:=
errorsParse
(
c
)
if
err
!=
nil
{
...
...
middleware/errors/errors.go
View file @
5f2670fd
...
...
@@ -34,6 +34,7 @@ func (h ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, er
if
h
.
Debug
{
// Write error to response instead of to log
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/plain; charset=utf-8"
)
w
.
WriteHeader
(
status
)
fmt
.
Fprintln
(
w
,
errMsg
)
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) {
// Write error and stack trace to the response rather than to a log
var
stackBuf
[
4096
]
byte
stack
:=
stackBuf
[
:
runtime
.
Stack
(
stackBuf
[
:
],
false
)]
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/plain; charset=utf-8"
)
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
fmt
.
Fprintf
(
w
,
"%s
\n\n
%s"
,
panicMsg
,
stack
)
}
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