Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
nexedi
gitlab-shell
Commits
3695d162
Commit
3695d162
authored
Jan 03, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set a 'Host' header on unix sockets
Workaround for a bug in the HTTPUNIX client.
parent
a3712cc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
14 deletions
+33
-14
lib/gitlab_net.rb
lib/gitlab_net.rb
+6
-0
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+27
-14
No files found.
lib/gitlab_net.rb
View file @
3695d162
...
...
@@ -159,6 +159,12 @@ class GitlabNet
request
.
set_form_data
(
params
.
merge
(
secret_token:
secret_token
))
if
uri
.
is_a?
(
URI
::
HTTPUNIX
)
# The HTTPUNIX HTTP client does not set a correct Host header. This can
# lead to 400 Bad Request responses.
request
[
'Host'
]
=
'localhost'
end
request
end
...
...
spec/gitlab_net_spec.rb
View file @
3695d162
...
...
@@ -248,24 +248,37 @@ describe GitlabNet, vcr: true do
end
describe
:http_request_for
do
let
(
:get
)
do
double
(
Net
::
HTTP
::
Get
).
tap
do
|
get
|
Net
::
HTTP
::
Get
.
stub
(
:new
)
{
get
}
context
'with stub'
do
let
(
:get
)
do
double
(
Net
::
HTTP
::
Get
).
tap
do
|
get
|
Net
::
HTTP
::
Get
.
stub
(
:new
)
{
get
}
end
end
let
(
:user
)
{
'user'
}
let
(
:password
)
{
'password'
}
let
(
:url
)
{
URI
'http://localhost/'
}
subject
{
gitlab_net
.
send
:http_request_for
,
:get
,
url
}
before
do
gitlab_net
.
send
(
:config
).
http_settings
.
stub
(
:[]
).
with
(
'user'
)
{
user
}
gitlab_net
.
send
(
:config
).
http_settings
.
stub
(
:[]
).
with
(
'password'
)
{
password
}
get
.
should_receive
(
:basic_auth
).
with
(
user
,
password
).
once
get
.
should_receive
(
:set_form_data
).
with
(
hash_including
(
secret_token:
'a123'
)).
once
end
it
{
should_not
be_nil
}
end
let
(
:user
)
{
'user'
}
let
(
:password
)
{
'password'
}
let
(
:url
)
{
URI
'http://localhost/'
}
subject
{
gitlab_net
.
send
:http_request_for
,
:get
,
url
}
before
do
gitlab_net
.
send
(
:config
).
http_settings
.
stub
(
:[]
).
with
(
'user'
)
{
user
}
gitlab_net
.
send
(
:config
).
http_settings
.
stub
(
:[]
).
with
(
'password'
)
{
password
}
get
.
should_receive
(
:basic_auth
).
with
(
user
,
password
).
once
get
.
should_receive
(
:set_form_data
).
with
(
hash_including
(
secret_token:
'a123'
)).
once
end
context
'Unix socket'
do
it
'sets the Host header to "localhost"'
do
gitlab_net
=
described_class
.
new
gitlab_net
.
should_receive
(
:secret_token
).
and_return
(
'a123'
)
it
{
should_not
be_nil
}
request
=
gitlab_net
.
send
(
:http_request_for
,
:get
,
URI
(
'http+unix://%2Ffoo'
))
expect
(
request
[
'Host'
]).
to
eq
(
'localhost'
)
end
end
end
describe
:cert_store
do
...
...
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