Disable redirections in HTTP based drivers

This commit is contained in:
Peter Knut 2024-01-25 13:43:18 +01:00 committed by Lionel Laffineur
parent 27132d1175
commit bc44e5f676
3 changed files with 11 additions and 5 deletions

View file

@ -18,9 +18,11 @@ if (isset($_GET["elastic"])) {
@ini_set('track_errors', 1); // @ - may be disabled
$file = @file_get_contents("$this->_url/" . ltrim($path, '/'), false, stream_context_create(array('http' => array(
'method' => $method,
'content' => $content === null ? $content : json_encode($content),
'header' => 'Content-Type: application/json',
'ignore_errors' => 1, // available since PHP 5.2.10
'content' => $content !== null ? json_encode($content) : null,
'header' => $content !== null ? 'Content-Type: application/json' : [],
'ignore_errors' => 1,
'follow_location' => 0,
'max_redirects' => 0,
))));
if (!$file) {
$this->error = error_get_last()['message'];

View file

@ -14,7 +14,9 @@ if (isset($_GET["clickhouse"])) {
'method' => 'POST',
'content' => $this->isQuerySelectLike($query) ? "$query FORMAT JSONCompact" : $query,
'header' => 'Content-type: application/x-www-form-urlencoded',
'ignore_errors' => 1, // available since PHP 5.2.10
'ignore_errors' => 1,
'follow_location' => 0,
'max_redirects' => 0,
))));
if ($file === false) {

View file

@ -425,7 +425,9 @@ if (isset($_GET["simpledb"])) {
$file = @file_get_contents((preg_match('~^https?://~', $host) ? $host : "http://$host"), false, stream_context_create(array('http' => array(
'method' => 'POST', // may not fit in URL with GET
'content' => $query,
'ignore_errors' => 1, // available since PHP 5.2.10
'ignore_errors' => 1,
'follow_location' => 0,
'max_redirects' => 0,
))));
if (!$file) {
$connection->error = $php_errormsg;