summaryrefslogtreecommitdiff
path: root/lib/gitlab/http_connection_adapter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/http_connection_adapter.rb')
-rw-r--r--lib/gitlab/http_connection_adapter.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/gitlab/http_connection_adapter.rb b/lib/gitlab/http_connection_adapter.rb
index 2152f619228..afb740a902b 100644
--- a/lib/gitlab/http_connection_adapter.rb
+++ b/lib/gitlab/http_connection_adapter.rb
@@ -24,11 +24,18 @@ module Gitlab
override :connection
def connection
- @uri, hostname = validate_url!(uri)
+ result = validate_url_with_proxy!(uri)
+ @uri = result.uri
+ hostname = result.hostname
http = super
http.hostname_override = hostname if hostname
+ unless result.use_proxy
+ http.proxy_from_env = false
+ http.proxy_address = nil
+ end
+
gitlab_http = Gitlab::NetHttpAdapter.new(http.address, http.port)
http.instance_variables.each do |variable|
@@ -40,12 +47,13 @@ module Gitlab
private
- def validate_url!(url)
- Gitlab::UrlBlocker.validate!(url, allow_local_network: allow_local_requests?,
- allow_localhost: allow_local_requests?,
- allow_object_storage: allow_object_storage?,
- dns_rebind_protection: dns_rebind_protection?,
- schemes: %w[http https])
+ def validate_url_with_proxy!(url)
+ Gitlab::UrlBlocker.validate_url_with_proxy!(
+ url, allow_local_network: allow_local_requests?,
+ allow_localhost: allow_local_requests?,
+ allow_object_storage: allow_object_storage?,
+ dns_rebind_protection: dns_rebind_protection?,
+ schemes: %w[http https])
rescue Gitlab::UrlBlocker::BlockedUrlError => e
raise Gitlab::HTTP::BlockedUrlError, "URL is blocked: #{e.message}"
end