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
iv
gitlab-shell
Commits
e07469ff
Commit
e07469ff
authored
Feb 09, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an HTTP timeout of 5 minutes by default
parent
82b3a4e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
config.yml.example
config.yml.example
+1
-0
lib/gitlab_net.rb
lib/gitlab_net.rb
+11
-6
No files found.
config.yml.example
View file @
e07469ff
...
...
@@ -17,6 +17,7 @@ gitlab_url: "http://localhost:8080"
# See installation.md#using-https for additional HTTPS configuration details.
http_settings:
# read_timeout: 300
# user: someone
# password: somepass
# ca_file: /etc/ssl/cert.pem
...
...
lib/gitlab_net.rb
View file @
e07469ff
...
...
@@ -10,6 +10,9 @@ require_relative 'httpunix'
class
GitlabNet
class
ApiUnreachableError
<
StandardError
;
end
CHECK_TIMEOUT
=
5
READ_TIMEOUT
=
300
def
check_access
(
cmd
,
repo
,
actor
,
changes
)
project_name
=
repo
.
gsub
(
"'"
,
""
)
project_name
=
project_name
.
gsub
(
/\.git\Z/
,
""
)
...
...
@@ -50,7 +53,7 @@ class GitlabNet
end
def
check
get
(
"
#{
host
}
/check"
)
get
(
"
#{
host
}
/check"
,
read_timeout:
CHECK_TIMEOUT
)
end
protected
...
...
@@ -63,13 +66,15 @@ class GitlabNet
"
#{
config
.
gitlab_url
}
/api/v3/internal"
end
def
http_client_for
(
uri
)
def
http_client_for
(
uri
,
options
=
{}
)
if
uri
.
is_a?
(
URI
::
HTTPUNIX
)
http
=
Net
::
HTTPUNIX
.
new
(
uri
.
hostname
)
else
http
=
Net
::
HTTP
.
new
(
uri
.
host
,
uri
.
port
)
end
http
.
read_timeout
=
options
[
:read_timeout
]
||
READ_TIMEOUT
if
uri
.
is_a?
(
URI
::
HTTPS
)
http
.
use_ssl
=
true
http
.
cert_store
=
cert_store
...
...
@@ -92,12 +97,12 @@ class GitlabNet
request
end
def
request
(
method
,
url
,
params
=
{})
def
request
(
method
,
url
,
params
=
{}
,
options
=
{}
)
$logger
.
debug
"Performing
#{
method
.
to_s
.
upcase
}
#{
url
}
"
uri
=
URI
.
parse
(
url
)
http
=
http_client_for
(
uri
)
http
=
http_client_for
(
uri
,
options
)
request
=
http_request_for
(
method
,
uri
,
params
)
begin
...
...
@@ -116,8 +121,8 @@ class GitlabNet
response
end
def
get
(
url
)
request
(
:get
,
url
)
def
get
(
url
,
options
=
{}
)
request
(
:get
,
url
,
{},
options
)
end
def
post
(
url
,
params
)
...
...
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