Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9a51f5c3
Commit
9a51f5c3
authored
Dec 21, 2016
by
Aron Fischer
Committed by
Felix Lange
Dec 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm/http: check error returned by reader.Size (#3470)
parent
301c0a63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
server.go
swarm/api/http/server.go
+13
-1
No files found.
swarm/api/http/server.go
View file @
9a51f5c3
...
@@ -99,7 +99,7 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
...
@@ -99,7 +99,7 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
"[BZZ] Swarm: Protocol error in request `%s`."
,
"[BZZ] Swarm: Protocol error in request `%s`."
,
uri
,
uri
,
)
)
http
.
Error
(
w
,
"
BZZ protocol error
"
,
http
.
StatusBadRequest
)
http
.
Error
(
w
,
"
Invalid request URL: need access protocol (bzz:/, bzzr:/, bzzi:/) as first element in path.
"
,
http
.
StatusBadRequest
)
return
return
}
}
}
}
...
@@ -187,6 +187,12 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
...
@@ -187,6 +187,12 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
reader
:=
a
.
Retrieve
(
key
)
reader
:=
a
.
Retrieve
(
key
)
quitC
:=
make
(
chan
bool
)
quitC
:=
make
(
chan
bool
)
size
,
err
:=
reader
.
Size
(
quitC
)
size
,
err
:=
reader
.
Size
(
quitC
)
if
err
!=
nil
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Could not determine size: %v"
,
err
.
Error
())
//An error on call to Size means we don't have the root chunk
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusNotFound
)
return
}
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Reading %d bytes."
,
size
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Reading %d bytes."
,
size
)
// setting mime type
// setting mime type
...
@@ -229,6 +235,12 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
...
@@ -229,6 +235,12 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
}
}
quitC
:=
make
(
chan
bool
)
quitC
:=
make
(
chan
bool
)
size
,
err
:=
reader
.
Size
(
quitC
)
size
,
err
:=
reader
.
Size
(
quitC
)
if
err
!=
nil
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Could not determine size: %v"
,
err
.
Error
())
//An error on call to Size means we don't have the root chunk
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusNotFound
)
return
}
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Served '%s' (%d bytes) as '%s' (status code: %v)"
,
uri
,
size
,
mimeType
,
status
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Served '%s' (%d bytes) as '%s' (status code: %v)"
,
uri
,
size
,
mimeType
,
status
)
http
.
ServeContent
(
w
,
r
,
path
,
forever
(),
reader
)
http
.
ServeContent
(
w
,
r
,
path
,
forever
(),
reader
)
...
...
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