Permalink
Browse files

Set 'Accepts: text/*' header by default.

  • Loading branch information...
1 parent 52d95b7 commit 8a891a52efe50a1806f16a848ede5e8d4769c3b6 @pmyteh pmyteh committed Jul 22, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 LIB_http.php
View
14 LIB_http.php
@@ -271,10 +271,11 @@ function http_header($target, $ref)
***********************************************************************/
function http($target, $ref, $method, $data_array, $incl_head)
{
- # XXX TODO: Send Accept: header for text/*, run and test for 406 responses
- # on otherwise acceptable downloads.
- # XXX TODO: Send Range:bytes=0-99999 header, run and test for 206 and 416
- # responses.
+ # XXX TODO: Run and test for 406 responses on otherwise acceptable
+ # downloads, as a result of the Accepts: header. This may
+ # well have a neglible effect: I understand many servers
+ # ignore it.
+ # XXX TODO: Run and test for 206 and 416 responses from Range: header.
# XXX TODO: Setup callback on HEAD to cancel download if given a
# content-type we can't handle
@@ -334,7 +335,10 @@ function http($target, $ref, $method, $data_array, $incl_head)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // Follow redirects
curl_setopt($ch, CURLOPT_MAXREDIRS, 4); // Limit redirections to four
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return in string
-
+ curl_setopt($ch,CURLOPT_HTTPHEADER,array('accept: text/*'); // Ask for text only
+ if ($fetchrangeonly == true)
+ curl_setopt($ch, CURLOPT_RANGE, "0-99999"); // Size limit
+
# Create return array
$return_array['FILE'] = curl_exec($ch);
$return_array['STATUS'] = curl_getinfo($ch);

0 comments on commit 8a891a5

Please sign in to comment.