Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
1eb38eed
Commit
1eb38eed
authored
May 09, 2009
by
Dries Buytaert
Browse files
- Patch
#280240
by c960657: don't add content length when there is no content in the request.
parent
76f35b4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/common.inc
View file @
1eb38eed
...
...
@@ -522,7 +522,6 @@ function drupal_http_request($url, array $options = array()) {
// Merge the default headers.
$options
[
'headers'
]
+=
array
(
'User-Agent'
=>
'Drupal (+http://drupal.org/)'
,
'Content-Length'
=>
strlen
(
$options
[
'data'
]),
);
// RFC 2616: "non-standard ports MUST, default ports MAY be included".
...
...
@@ -530,7 +529,15 @@ function drupal_http_request($url, array $options = array()) {
// checking the host that do not take into account the port number.
$options
[
'headers'
][
'Host'
]
=
$host
;
// If the server url has a user then attempt to use basic authentication
// Only add Content-Length if we actually have any content or if it is a POST
// or PUT request. Some non-standard servers get confused by Content-Length in
// at least HEAD/GET requests, and Squid always requires Content-Length in
// POST/PUT requests.
if
(
!
empty
(
$options
[
'data'
])
||
$options
[
'method'
]
==
'POST'
||
$options
[
'method'
]
==
'PUT'
)
{
$options
[
'headers'
][
'Content-Length'
]
=
strlen
(
$options
[
'data'
]);
}
// If the server URL has a user then attempt to use basic authentication.
if
(
isset
(
$uri
[
'user'
]))
{
$options
[
'headers'
][
'Authorization'
]
=
'Basic '
.
base64_encode
(
$uri
[
'user'
]
.
(
!
empty
(
$uri
[
'pass'
])
?
":"
.
$uri
[
'pass'
]
:
''
));
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment