Skip to content

Commit

Permalink
Added option to pass alternative User-Agent header to 'io_download()'
Browse files Browse the repository at this point in the history
This change is required to enable the extension manager to use a different
User-Agent HTTP header on downloading plugin archives for installation. See #2410.
  • Loading branch information
lpaulsen93 committed Jun 8, 2018
1 parent 9bd73f3 commit 6df0bbd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion inc/io.php
Expand Up @@ -649,14 +649,18 @@ function io_mktmpdir() {
* @param bool $useAttachment if true: try to use name of download, uses otherwise $defaultName, false: uses $file as path to file
* @param string $defaultName fallback for if using $useAttachment
* @param int $maxSize maximum file size
* @param string $agent alternative HTTP user-agent header
* @return bool|string if failed false, otherwise true or the name of the file in the given dir
*/
function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=2097152){
function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=2097152,$agent=null){
global $conf;
$http = new DokuHTTPClient();
$http->max_bodysize = $maxSize;
$http->timeout = 25; //max. 25 sec
$http->keep_alive = false; // we do single ops here, no need for keep-alive
if ($agent !== null) {
$http->agent = $agent;
}

$data = $http->get($url);
if(!$data) return false;
Expand Down

0 comments on commit 6df0bbd

Please sign in to comment.