Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbiat committed May 12, 2021
1 parent 44f5a8c commit d5db7ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ public function links(array $links = [], string $type = 'header', bool $strictRe
}
} else {
if ($type === 'header') {
header('Link: '.implode(', ', $linksToSend), false);
header('Link: '.preg_replace('/[\r\n]/i', '', implode(', ', $linksToSend)), false);
return $this;
} else {
return implode("\r\n", $linksToSend);
Expand Down
10 changes: 8 additions & 2 deletions src/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,11 +921,16 @@ public function proxyFile(string $url, string $cacheStrat = ''): void
#Cache headers object
$headers = (new \Simbiat\http20\Headers);
#Get headers
$headersData = get_headers($url, context: stream_context_create(['http' => [
$headersData = @get_headers($url, context: stream_context_create(['http' => [
'method' => 'HEAD',
'follow_location' => 1,
'protocol_version' => 2.0
]]));
#Check that we did get headers
if (!is_array($headersData)) {
#Failed to get headers, meaning we most likely will not be able to get the content as well
$headers->clientReturn('500', true);
}
#Cache-Control flag
$cache = false;
#Send the headers from remote server
Expand All @@ -948,7 +953,8 @@ public function proxyFile(string $url, string $cacheStrat = ''): void
}
}
#Open streams
$url = fopen($url, 'rb', context: stream_context_create(['http' => [
#Supress warning for $url, since connection can be refused for some reason and it still may be "normal"
$url = @fopen($url, 'rb', context: stream_context_create(['http' => [
'method' => 'GET',
'follow_location' => 1,
'protocol_version' => 2.0
Expand Down

0 comments on commit d5db7ef

Please sign in to comment.