Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-workhorse
Commits
30884ebf
Commit
30884ebf
authored
Jan 14, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix authorization request
parent
a9058bcd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
internal/api/api.go
internal/api/api.go
+30
-3
No files found.
internal/api/api.go
View file @
30884ebf
...
...
@@ -60,12 +60,39 @@ type Response struct {
TempPath
string
}
// singleJoiningSlash is taken from reverseproxy.go:NewSingleHostReverseProxy
func
singleJoiningSlash
(
a
,
b
string
)
string
{
aslash
:=
strings
.
HasSuffix
(
a
,
"/"
)
bslash
:=
strings
.
HasPrefix
(
b
,
"/"
)
switch
{
case
aslash
&&
bslash
:
return
a
+
b
[
1
:
]
case
!
aslash
&&
!
bslash
:
return
a
+
"/"
+
b
}
return
a
+
b
}
// rebaseUrl is taken from reverseproxy.go:NewSingleHostReverseProxy
func
rebaseUrl
(
url
*
url
.
URL
,
onto
*
url
.
URL
,
suffix
string
)
*
url
.
URL
{
newUrl
:=
*
url
newUrl
.
Scheme
=
onto
.
Scheme
newUrl
.
Host
=
onto
.
Host
if
suffix
!=
""
{
newUrl
.
Path
=
singleJoiningSlash
(
url
.
Path
,
suffix
)
}
if
onto
.
RawQuery
==
""
||
newUrl
.
RawQuery
==
""
{
newUrl
.
RawQuery
=
onto
.
RawQuery
+
newUrl
.
RawQuery
}
else
{
newUrl
.
RawQuery
=
onto
.
RawQuery
+
"&"
+
newUrl
.
RawQuery
}
return
&
newUrl
}
func
(
api
*
API
)
newRequest
(
r
*
http
.
Request
,
body
io
.
Reader
,
suffix
string
)
(
*
http
.
Request
,
error
)
{
url
:=
*
api
.
URL
// Make a copy of api.URL
url
.
Path
=
r
.
URL
.
RequestURI
()
+
suffix
authReq
:=
&
http
.
Request
{
Method
:
r
.
Method
,
URL
:
&
url
,
URL
:
rebaseUrl
(
r
.
URL
,
api
.
URL
,
suffix
)
,
Header
:
proxy
.
HeaderClone
(
r
.
Header
),
}
if
body
!=
nil
{
...
...
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