Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
ddee3f9f
Commit
ddee3f9f
authored
11 years ago
by
VladimirAus
Committed by
Chris Leppanen
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #1159806 by VladimirAus, bigjim | Slim Pickens: Added proxy support.
parent
7e6679d2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/http_request.inc
+28
-0
28 additions, 0 deletions
libraries/http_request.inc
with
28 additions
and
0 deletions
libraries/http_request.inc
+
28
−
0
View file @
ddee3f9f
...
...
@@ -178,6 +178,22 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
curl_setopt
(
$download
,
CURLOPT_RETURNTRANSFER
,
TRUE
);
curl_setopt
(
$download
,
CURLOPT_ENCODING
,
''
);
curl_setopt
(
$download
,
CURLOPT_TIMEOUT
,
$request_timeout
);
$proxy_server
=
variable_get
(
'proxy_server'
);
if
(
$proxy_server
&&
_drupal_http_use_proxy
(
$uri
[
'host'
]))
{
curl_setopt
(
$download
,
CURLOPT_PROXY
,
$proxy_server
);
curl_setopt
(
$download
,
CURLOPT_PROXYPORT
,
variable_get
(
'proxy_port'
,
8080
));
// Proxy user/password.
if
(
$proxy_username
=
variable_get
(
'proxy_username'
))
{
$username_password
=
$proxy_username
.
':'
.
variable_get
(
'proxy_password'
,
''
);
curl_setopt
(
$download
,
CURLOPT_PROXYUSERPWD
,
$username_password
);
curl_setopt
(
$download
,
CURLOPT_PROXYAUTH
,
variable_get
(
'proxy_auth_method'
,
CURLAUTH_BASIC
));
}
}
if
(
$accept_invalid_cert
)
{
curl_setopt
(
$download
,
CURLOPT_SSL_VERIFYPEER
,
0
);
}
...
...
@@ -193,6 +209,18 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
);
}
// When using a proxy, remove extra data from the header which is not
// considered by CURLINFO_HEADER_SIZE (possibly cURL bug).
// This data is only added when to HTTP header when working with a proxy.
// Example string added: <HTTP/1.0 200 Connection established\r\n\r\n>
if
(
$proxy_server
&&
_drupal_http_use_proxy
(
$uri
[
'host'
]))
{
$http_header_break
=
"
\r\n\r\n
"
;
$response
=
explode
(
$http_header_break
,
$data
);
if
(
count
(
$response
)
>
2
)
{
$data
=
substr
(
$data
,
strlen
(
$response
[
0
]
.
$http_header_break
),
strlen
(
$data
));
}
}
$header_size
=
curl_getinfo
(
$download
,
CURLINFO_HEADER_SIZE
);
$header
=
substr
(
$data
,
0
,
$header_size
-
1
);
$result
->
data
=
substr
(
$data
,
$header_size
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment