Skip to content

Commit

Permalink
Fix bug: HTTP HEAD requests don't work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaswolf committed Dec 28, 2011
1 parent 1e7c3a7 commit aefe0c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Sabre/DAV/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,13 @@ public function request($method, $url = '', $body = null, $headers = array()) {
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_POSTFIELDS => $body,
// Return headers as part of the response
CURLOPT_HEADER => true
CURLOPT_HEADER => true,
// do not read body with HEAD requests (this is neccessary because cURL does not ignore the body with HEAD
// requests when the Content-Length header is given - which in turn is perfectly valid according to HTTP
// specs...) cURL does unfortunately return an error in this case ("transfer closed transfer closed with
// ... bytes remaining to read") this can be circumvented by explicitly telling cURL to ignore the
// response body
CURLOPT_NOBODY => ($method == 'HEAD')
);

// Adding HTTP headers
Expand Down

0 comments on commit aefe0c9

Please sign in to comment.