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
0700c74b
Unverified
Commit
0700c74b
authored
Nov 10, 2020
by
Adin Schmahmann
Committed by
GitHub
Nov 10, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7727 from ipfs/fix/preserver-query-on-website-redirect
fix(gw): preserve query on website redirect
parents
675ef92a
6ffd0aa2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
core/corehttp/gateway_handler.go
core/corehttp/gateway_handler.go
+6
-1
test/sharness/t0110-gateway.sh
test/sharness/t0110-gateway.sh
+12
-1
No files found.
core/corehttp/gateway_handler.go
View file @
0700c74b
...
...
@@ -290,7 +290,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
goget
:=
r
.
URL
.
Query
()
.
Get
(
"go-get"
)
==
"1"
if
dirwithoutslash
&&
!
goget
{
// See comment above where originalUrlPath is declared.
http
.
Redirect
(
w
,
r
,
originalUrlPath
+
"/"
,
302
)
suffix
:=
"/"
if
r
.
URL
.
RawQuery
!=
""
{
// preserve query parameters
suffix
=
suffix
+
"?"
+
r
.
URL
.
RawQuery
}
http
.
Redirect
(
w
,
r
,
originalUrlPath
+
suffix
,
302
)
return
}
...
...
test/sharness/t0110-gateway.sh
View file @
0700c74b
...
...
@@ -54,8 +54,9 @@ test_expect_success "GET IPFS path output looks good" '
'
test_expect_success
"GET IPFS directory path succeeds"
'
mkdir
dir
&&
mkdir
-p dir/dirwithindex
&&
echo "12345" >dir/test &&
echo "hello i am a webpage" >dir/dirwithindex/index.html &&
ipfs add -r -q dir >actual &&
HASH2=$(tail -n 1 actual) &&
curl -sf "http://127.0.0.1:$port/ipfs/$HASH2"
...
...
@@ -69,6 +70,16 @@ test_expect_success "GET IPFS directory file output looks good" '
test_cmp dir/test actual
'
test_expect_success
"GET IPFS directory with index.html returns redirect to add trailing slash"
"
curl -sI -o response_without_slash
\"
http://127.0.0.1:
$port
/ipfs/
$HASH2
/dirwithindex?query=to-remember
\"
&&
test_should_contain
\"
Location: /ipfs/
$HASH2
/dirwithindex/?query=to-remember
\"
response_without_slash
"
test_expect_success
"GET IPFS directory with index.html and trailing slash returns expected output"
"
curl -s -o response_with_slash
\"
http://127.0.0.1:
$port
/ipfs/
$HASH2
/dirwithindex/?query=to-remember
\"
&&
test_should_contain
\"
hello i am a webpage
\"
response_with_slash
"
test_expect_success
"GET IPFS nonexistent file returns code expected (404)"
'
test_curl_resp_http_code "http://127.0.0.1:$port/ipfs/$HASH2/pleaseDontAddMe" "HTTP/1.1 404 Not Found"
'
...
...
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