Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3bb4d6f0
authored
2014-07-08 23:20:55 +0300
by
Christoph Portmann
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
beego/context: Fix ignored Header in case SetStatus has been called before
1 parent
fefd8ddb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
context/output.go
router.go
context/output.go
View file @
3bb4d6f
...
...
@@ -71,6 +71,14 @@ func (output *BeegoOutput) Body(content []byte) {
}
else
{
output
.
Header
(
"Content-Length"
,
strconv
.
Itoa
(
len
(
content
)))
}
// Write status code if it has been set manually
// Set it to 0 afterwards to prevent "multiple response.WriteHeader calls"
if
output
.
Status
!=
0
{
output
.
Context
.
ResponseWriter
.
WriteHeader
(
output
.
Status
)
output
.
Status
=
0
}
output_writer
.
Write
(
content
)
switch
output_writer
.
(
type
)
{
case
*
gzip
.
Writer
:
...
...
@@ -270,7 +278,6 @@ func (output *BeegoOutput) ContentType(ext string) {
// SetStatus sets response status code.
// It writes response header directly.
func
(
output
*
BeegoOutput
)
SetStatus
(
status
int
)
{
output
.
Context
.
ResponseWriter
.
WriteHeader
(
status
)
output
.
Status
=
status
}
...
...
router.go
View file @
3bb4d6f
...
...
@@ -762,6 +762,11 @@ Admin:
Info
(
"beego:"
+
r
.
URL
.
Path
+
" 404"
+
" +"
+
timeend
.
String
())
}
}
// Call WriteHeader if status code has been set changed
if
context
.
Output
.
Status
!=
0
{
w
.
writer
.
WriteHeader
(
context
.
Output
.
Status
)
}
}
func
(
p
*
ControllerRegistor
)
recoverPanic
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment