Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
8176766d
Commit
8176766d
authored
Jul 27, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
naming and cleanup
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
0c4b10af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
18 deletions
+2
-18
commands/http/handler.go
commands/http/handler.go
+2
-18
No files found.
commands/http/handler.go
View file @
8176766d
...
...
@@ -204,14 +204,14 @@ func sendResponse(w http.ResponseWriter, req cmds.Request, res cmds.Response) {
h
.
Set
(
streamHeader
,
"1"
)
h
.
Set
(
transferEncodingHeader
,
"chunked"
)
if
err
:=
copyChunks
(
status
,
w
,
out
);
err
!=
nil
{
if
err
:=
writeResponse
(
status
,
w
,
out
);
err
!=
nil
{
log
.
Error
(
"error while writing stream"
,
err
)
}
}
// Copies from an io.Reader to a http.ResponseWriter.
// Flushes chunks over HTTP stream as they are read (if supported by transport).
func
copyChunks
(
status
int
,
w
http
.
ResponseWriter
,
out
io
.
Reader
)
error
{
func
writeResponse
(
status
int
,
w
http
.
ResponseWriter
,
out
io
.
Reader
)
error
{
// hijack the connection so we can write our own chunked output and trailers
hijacker
,
ok
:=
w
.
(
http
.
Hijacker
)
if
!
ok
{
...
...
@@ -283,19 +283,3 @@ func sanitizedErrStr(err error) string {
s
=
strings
.
Split
(
s
,
"
\r
"
)[
0
]
return
s
}
type
flushResponse
struct
{
W
http
.
ResponseWriter
}
func
(
fr
*
flushResponse
)
Write
(
buf
[]
byte
)
(
int
,
error
)
{
n
,
err
:=
fr
.
W
.
Write
(
buf
)
if
err
!=
nil
{
return
n
,
err
}
if
flusher
,
ok
:=
fr
.
W
.
(
http
.
Flusher
);
ok
{
flusher
.
Flush
()
}
return
n
,
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