Enable curl for #79

This commit is contained in:
djmaze 2021-04-12 15:12:24 +02:00
parent c5d4e5f395
commit 47a5b2e268
3 changed files with 9 additions and 3 deletions

View file

@ -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;

View file

@ -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);
}

View file

@ -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']);