Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
93a82c30
Commit
93a82c30
authored
Mar 27, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Updating proxy to return 301 to add a "/" at the end for #4958"
parent
db189c0d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
65 deletions
+0
-65
proxy.go
pkg/apiserver/proxy.go
+0
-9
proxy_test.go
pkg/apiserver/proxy_test.go
+0
-56
No files found.
pkg/apiserver/proxy.go
View file @
93a82c30
...
...
@@ -191,15 +191,6 @@ func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}
// Redirect requests of the form "/{resource}/{name}" to "/{resource}/{name}/"
// This is essentially a hack for https://github.com/GoogleCloudPlatform/kubernetes/issues/4958.
// Note: Keep this code after tryUpgrade to not break that flow.
if
len
(
parts
)
==
2
&&
!
strings
.
HasSuffix
(
req
.
URL
.
Path
,
"/"
)
{
w
.
Header
()
.
Set
(
"Location"
,
req
.
URL
.
Path
+
"/"
)
w
.
WriteHeader
(
http
.
StatusMovedPermanently
)
return
}
proxy
:=
httputil
.
NewSingleHostReverseProxy
(
&
url
.
URL
{
Scheme
:
location
.
Scheme
,
Host
:
location
.
Host
})
if
transport
==
nil
{
prepend
:=
path
.
Join
(
r
.
prefix
,
resource
,
id
)
...
...
pkg/apiserver/proxy_test.go
View file @
93a82c30
...
...
@@ -367,59 +367,3 @@ func TestProxyUpgrade(t *testing.T) {
t
.
Fatalf
(
"expected '%#v', got '%#v'"
,
e
,
a
)
}
}
func
TestRedirectOnMissingTrailingSlash
(
t
*
testing
.
T
)
{
table
:=
[]
struct
{
// The requested path
path
string
// The path requested on the proxy server.
proxyServerPath
string
}{
{
"/trailing/slash/"
,
"/trailing/slash/"
},
{
"/"
,
"/"
},
// "/" should be added at the end.
{
""
,
"/"
},
// "/" should not be added at a non-root path.
{
"/some/path"
,
"/some/path"
},
}
for
_
,
item
:=
range
table
{
proxyServer
:=
httptest
.
NewServer
(
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
if
req
.
URL
.
Path
!=
item
.
proxyServerPath
{
t
.
Errorf
(
"Unexpected request on path: %s, expected path: %s, item: %v"
,
req
.
URL
.
Path
,
item
.
proxyServerPath
,
item
)
}
}))
defer
proxyServer
.
Close
()
serverURL
,
_
:=
url
.
Parse
(
proxyServer
.
URL
)
simpleStorage
:=
&
SimpleRESTStorage
{
errors
:
map
[
string
]
error
{},
resourceLocation
:
serverURL
,
expectedResourceNamespace
:
"ns"
,
}
handler
:=
handleNamespaced
(
map
[
string
]
rest
.
Storage
{
"foo"
:
simpleStorage
})
server
:=
httptest
.
NewServer
(
handler
)
defer
server
.
Close
()
proxyTestPattern
:=
"/api/version/proxy/namespaces/ns/foo/id"
+
item
.
path
req
,
err
:=
http
.
NewRequest
(
"GET"
,
server
.
URL
+
proxyTestPattern
,
strings
.
NewReader
(
""
),
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error %v"
,
err
)
continue
}
// Note: We are using a default client here, that follows redirects.
resp
,
err
:=
http
.
DefaultClient
.
Do
(
req
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error %v"
,
err
)
continue
}
if
resp
.
StatusCode
!=
200
{
t
.
Errorf
(
"Unexpected errorCode: %v, expected: 200. Response: %v, item: %v"
,
resp
.
StatusCode
,
resp
,
item
)
}
}
}
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