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
ef5f9c77
Commit
ef5f9c77
authored
Feb 24, 2016
by
Benoit Benedetti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FastCGI: Explicitly set Content-Length #626
parent
05957b49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+10
-1
No files found.
middleware/fastcgi/fastcgi.go
100755 → 100644
View file @
ef5f9c77
...
...
@@ -4,6 +4,7 @@
package
fastcgi
import
(
"bytes"
"errors"
"io"
"net/http"
...
...
@@ -105,13 +106,21 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
return
http
.
StatusBadGateway
,
err
}
// Write the response body to a buffer
// To explicitly set Content-Length
// For FastCGI app that don't set it
var
buf
bytes
.
Buffer
io
.
Copy
(
&
buf
,
resp
.
Body
)
if
r
.
Header
.
Get
(
"Content-Length"
)
==
""
{
w
.
Header
()
.
Set
(
"Content-Length"
,
strconv
.
Itoa
(
buf
.
Len
()))
}
writeHeader
(
w
,
resp
)
// Write the response body
// TODO: If this has an error, the response will already be
// partly written. We should copy out of resp.Body into a buffer
// first, then write it to the response...
_
,
err
=
io
.
Copy
(
w
,
resp
.
Body
)
_
,
err
=
io
.
Copy
(
w
,
&
buf
)
if
err
!=
nil
{
return
http
.
StatusBadGateway
,
err
}
...
...
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