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
cbccd847
Commit
cbccd847
authored
Oct 20, 2017
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateway: apply review to serveFile
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
913f9641
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
9 deletions
+2
-9
core/corehttp/gateway_handler.go
core/corehttp/gateway_handler.go
+2
-9
No files found.
core/corehttp/gateway_handler.go
View file @
cbccd847
...
...
@@ -268,7 +268,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
if
!
dir
{
name
:=
gopath
.
Base
(
urlPath
)
i
.
serve
r
File
(
w
,
r
,
name
,
modtime
,
dr
)
i
.
serveFile
(
w
,
r
,
name
,
modtime
,
dr
)
return
}
...
...
@@ -390,7 +390,7 @@ func (s *sizeSeeker) Seek(offset int64, whence int) (int64, error) {
return
s
.
sizeReadSeeker
.
Seek
(
offset
,
whence
)
}
func
(
i
*
gatewayHandler
)
serve
r
File
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
name
string
,
modtime
time
.
Time
,
content
io
.
ReadSeeker
)
{
func
(
i
*
gatewayHandler
)
serveFile
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
name
string
,
modtime
time
.
Time
,
content
io
.
ReadSeeker
)
{
if
sp
,
ok
:=
content
.
(
sizeReadSeeker
);
ok
{
content
=
&
sizeSeeker
{
sizeReadSeeker
:
sp
,
...
...
@@ -398,13 +398,6 @@ func (i *gatewayHandler) serverFile(w http.ResponseWriter, req *http.Request, na
}
http
.
ServeContent
(
w
,
req
,
name
,
modtime
,
content
)
//TODO: check for errors in ServeContent.. somehow
// If http.ServeContent can't figure out content size it won't write it to the
// responseWriter, Content-Length not being set is a good indicator of this
if
req
.
Method
!=
"HEAD"
&&
w
.
Header
()
.
Get
(
"Content-Length"
)
==
""
{
io
.
Copy
(
w
,
content
)
}
}
func
(
i
*
gatewayHandler
)
postHandler
(
ctx
context
.
Context
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
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