mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Resolve mail redirects https://github.com/the-djmaze/snappymail/issues/234#issuecomment-1040120224#234
This commit is contained in:
parent
9b82830c36
commit
fca464f0b2
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -67,6 +67,11 @@ class Response
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getHeaders() : array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function getRedirectLocation() : ?string
|
||||
{
|
||||
if ($location = $this->getHeader('location')) {
|
||||
|
|
Loading…
Reference in a new issue