the-djmaze 2022-02-15 11:43:18 +01:00
parent 9b82830c36
commit fca464f0b2
4 changed files with 9 additions and 0 deletions

View file

@ -351,6 +351,7 @@ class ServiceActions
\header('X-Content-Location: '.$aData['Url']);
$tmp = \tmpfile();
$HTTP = \SnappyMail\HTTP\Request::factory();
$HTTP->max_redirects = 2;
$HTTP->streamBodyTo($tmp);
$oResponse = $HTTP->doRequest('GET', $aData['Url']);
if ($oResponse && 200 === $oResponse->status
@ -360,6 +361,7 @@ class ServiceActions
\header('Content-Type: ' . $oResponse->getHeader('content-type'));
\header('Cache-Control: public');
\header('Expires: '.\gmdate('D, j M Y H:i:s', 2592000 + \time()).' UTC');
\header('X-Content-Redirect-Location: '.$oResponse->final_uri);
\rewind($tmp);
\fpassthru($tmp);
exit;

View file

@ -129,6 +129,7 @@ abstract class Request
throw new \RuntimeException("Fetching URL not allowed: {$url}");
}
$this->stream && \rewind($this->stream);
$result = $this->__doRequest($method, $url, $body, \array_merge($this->headers, $extra_headers));
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3

View file

@ -157,6 +157,7 @@ class Socket extends \SnappyMail\HTTP\Request
"\r\n" === \fread($sock, 2);
} else {
\fwrite($this->stream, \fread($sock, 1024));
// \stream_copy_to_stream($sock, $this->stream);
}
}
} else {

View file

@ -67,6 +67,11 @@ class Response
return null;
}
public function getHeaders() : array
{
return $this->headers;
}
public function getRedirectLocation() : ?string
{
if ($location = $this->getHeader('location')) {