mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-21 14:22:23 +08:00
Enable curl for #79
This commit is contained in:
parent
c5d4e5f395
commit
47a5b2e268
3 changed files with 9 additions and 3 deletions
|
@ -46,7 +46,7 @@ class Client
|
|||
}
|
||||
$this->baseUri = $settings['baseUri'];
|
||||
|
||||
$this->HTTP = \SnappyMail\HTTP\Request::factory('socket');
|
||||
$this->HTTP = \SnappyMail\HTTP\Request::factory(/*'socket'*/);
|
||||
$this->HTTP->proxy = $settings['proxy'] ?? null;
|
||||
$this->HTTP->setAuth(3, $settings['userName'] ?? '', $settings['password'] ?? '');
|
||||
$this->HTTP->max_response_kb = 0;
|
||||
|
|
|
@ -94,7 +94,13 @@ class CURL extends \SnappyMail\HTTP\Request
|
|||
|
||||
protected function fetchHeader($ch, $header)
|
||||
{
|
||||
$this->response_headers[] = \rtrim($header);
|
||||
static $headers = [];
|
||||
if (!\strlen(\rtrim($header))) {
|
||||
$this->response_headers = $headers;
|
||||
$headers = [];
|
||||
} else {
|
||||
$headers[] = \rtrim($header);
|
||||
}
|
||||
return \strlen($header);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class Socket extends \SnappyMail\HTTP\Request
|
|||
$response_headers[] = $data;
|
||||
$chunked |= \preg_match('#Transfer-Encoding:.*chunked#i', $data);
|
||||
|
||||
if (401 === $code && $this->auth['user']) {
|
||||
if (401 === $code && $this->auth['user'] && !isset($extra_headers['Authorization'])) {
|
||||
// Basic authentication
|
||||
if ($this->auth['type'] & self::AUTH_BASIC && \preg_match("/WWW-Authenticate:\\s+Basic\\s+realm=([^\\r\\n]*)/i", $data, $match)) {
|
||||
$extra_headers['Authorization'] = "Authorization: Basic " . \base64_encode($this->auth['user'] . ':' . $this->auth['pass']);
|
||||
|
|
Loading…
Reference in a new issue