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
628245ff
Commit
628245ff
authored
Jun 27, 2017
by
Jeromy Johnson
Committed by
GitHub
Jun 27, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4005 from ipfs/fix/404msg
Show escaped url in gateway 404 message
parents
b0b32400
5ebf897f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
core/corehttp/gateway_handler.go
core/corehttp/gateway_handler.go
+5
-4
core/corehttp/gateway_test.go
core/corehttp/gateway_test.go
+1
-0
No files found.
core/corehttp/gateway_handler.go
View file @
628245ff
...
...
@@ -134,6 +134,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request)
func
(
i
*
gatewayHandler
)
getOrHeadHandler
(
ctx
context
.
Context
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
urlPath
:=
r
.
URL
.
Path
escapedURLPath
:=
r
.
URL
.
EscapedPath
()
// If the gateway is behind a reverse proxy and mounted at a sub-path,
// the prefix header can be set to signal this sub-path.
...
...
@@ -173,12 +174,12 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
case
nil
:
case
coreiface
.
ErrOffline
:
if
!
i
.
node
.
OnlineMode
()
{
webError
(
w
,
"ipfs resolve -r "
+
url
Path
,
err
,
http
.
StatusServiceUnavailable
)
webError
(
w
,
"ipfs resolve -r "
+
escapedURL
Path
,
err
,
http
.
StatusServiceUnavailable
)
return
}
fallthrough
default
:
webError
(
w
,
"ipfs resolve -r "
+
url
Path
,
err
,
http
.
StatusNotFound
)
webError
(
w
,
"ipfs resolve -r "
+
escapedURL
Path
,
err
,
http
.
StatusNotFound
)
return
}
...
...
@@ -191,7 +192,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
case
coreiface
.
ErrIsDir
:
dir
=
true
default
:
webError
(
w
,
"ipfs cat "
+
url
Path
,
err
,
http
.
StatusNotFound
)
webError
(
w
,
"ipfs cat "
+
escapedURL
Path
,
err
,
http
.
StatusNotFound
)
return
}
...
...
@@ -278,7 +279,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
ixnd
,
err
:=
dirr
.
Find
(
ctx
,
"index.html"
)
switch
{
case
err
==
nil
:
log
.
Debugf
(
"found index.html link for %s"
,
url
Path
)
log
.
Debugf
(
"found index.html link for %s"
,
escapedURL
Path
)
dirwithoutslash
:=
urlPath
[
len
(
urlPath
)
-
1
]
!=
'/'
goget
:=
r
.
URL
.
Query
()
.
Get
(
"go-get"
)
==
"1"
...
...
core/corehttp/gateway_test.go
View file @
628245ff
...
...
@@ -140,6 +140,7 @@ func TestGatewayGet(t *testing.T) {
{
"localhost:5001"
,
"/"
+
k
,
http
.
StatusNotFound
,
"404 page not found
\n
"
},
{
"localhost:5001"
,
"/ipfs/"
+
k
,
http
.
StatusOK
,
"fnord"
},
{
"localhost:5001"
,
"/ipns/nxdomain.example.com"
,
http
.
StatusNotFound
,
"ipfs resolve -r /ipns/nxdomain.example.com: "
+
namesys
.
ErrResolveFailed
.
Error
()
+
"
\n
"
},
{
"localhost:5001"
,
"/ipns/%0D%0A%0D%0Ahello"
,
http
.
StatusNotFound
,
"ipfs resolve -r /ipns/%0D%0A%0D%0Ahello: "
+
namesys
.
ErrResolveFailed
.
Error
()
+
"
\n
"
},
{
"localhost:5001"
,
"/ipns/example.com"
,
http
.
StatusOK
,
"fnord"
},
{
"example.com"
,
"/"
,
http
.
StatusOK
,
"fnord"
},
}
{
...
...
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