Merge pull request #3958 from alchemy-fr/PHRAS-3637-use-correct-guzzle-version

PHRAS-3637 merge API - Upload Url | Let's Encrypt ssl certificate verification fail. use the correct guzzle version
This commit is contained in:
Nicolas Maillat
2022-02-07 16:56:45 +01:00
committed by GitHub
3 changed files with 13 additions and 13 deletions

View File

@@ -92,7 +92,7 @@ use Alchemy\Phrasea\WorkerManager\Event\AssetsCreateEvent;
use Alchemy\Phrasea\WorkerManager\Event\RecordsWriteMetaEvent; use Alchemy\Phrasea\WorkerManager\Event\RecordsWriteMetaEvent;
use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents; use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Guzzle\Http\Client as Guzzle; use GuzzleHttp\Client as Guzzle;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use media_subdef; use media_subdef;
use Neutron\TemporaryFilesystem\TemporaryFilesystemInterface; use Neutron\TemporaryFilesystem\TemporaryFilesystemInterface;
@@ -963,8 +963,8 @@ class V1Controller extends Controller
$tempfile = $tmpFs->createTemporaryFile('download_', null, $pi['extension']); $tempfile = $tmpFs->createTemporaryFile('download_', null, $pi['extension']);
try { try {
$guzzle = new Guzzle($url); $guzzle = new Guzzle(['base_uri' => $url]);
$res = $guzzle->get("", [], ['save_to' => $tempfile])->send(); $res = $guzzle->get("", ['save_to' => $tempfile]);
} }
catch (\Exception $e) { catch (\Exception $e) {
return $this->getBadRequestAction($request, sprintf('Error "%s" downloading "%s"', $e->getMessage(), $url)); return $this->getBadRequestAction($request, sprintf('Error "%s" downloading "%s"', $e->getMessage(), $url));

View File

@@ -21,7 +21,7 @@ use Alchemy\Phrasea\Model\Entities\LazaretSession;
use collection; use collection;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Exception; use Exception;
use Guzzle\Http\Client as Guzzle; use GuzzleHttp\Client as Guzzle;
use Neutron\TemporaryFilesystem\TemporaryFilesystemInterface; use Neutron\TemporaryFilesystem\TemporaryFilesystemInterface;
use p4field; use p4field;
use record_adapter; use record_adapter;
@@ -104,8 +104,8 @@ class V3RecordController extends Controller
$tempfile = $tmpFs->createTemporaryFile('download_', null, $pi['extension']); $tempfile = $tmpFs->createTemporaryFile('download_', null, $pi['extension']);
try { try {
$guzzle = new Guzzle($url); $guzzle = new Guzzle(['base_uri' => $url]);
$res = $guzzle->get("", [], ['save_to' => $tempfile])->send(); $res = $guzzle->get("", ['save_to' => $tempfile]);
} }
catch (Exception $e) { catch (Exception $e) {
return Result::createBadRequest($request, sprintf('Error "%s" downloading "%s"', $e->getMessage(), $url)); return Result::createBadRequest($request, sprintf('Error "%s" downloading "%s"', $e->getMessage(), $url));

View File

@@ -26,7 +26,7 @@ use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Alchemy\Phrasea\Model\Entities\LazaretSession; use Alchemy\Phrasea\Model\Entities\LazaretSession;
use DataURI\Exception\Exception as DataUriException; use DataURI\Exception\Exception as DataUriException;
use DataURI\Parser; use DataURI\Parser;
use Guzzle\Http\Client as Guzzle; use GuzzleHttp\Client as Guzzle;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -88,10 +88,10 @@ class UploadController extends Controller
$url = $request->get('url'); $url = $request->get('url');
$basename = pathinfo($url, PATHINFO_BASENAME); $basename = pathinfo($url, PATHINFO_BASENAME);
$guzzle = new Guzzle($url); $guzzle = new Guzzle(['base_uri' => $url]);
$res = $guzzle->head("")->send(); $res = $guzzle->head('');
$response['content-type'] = $res->getContentType(); $response['content-type'] = $res->getHeaderLine('content-type');
$response['content-length'] = $res->getContentLength(); $response['content-length'] = doubleval($res->getHeaderLine('content-length'));
$response['basename'] = $basename; $response['basename'] = $basename;
} }
catch (\Exception $e) { catch (\Exception $e) {
@@ -161,8 +161,8 @@ class UploadController extends Controller
$tempfile = $this->getTemporaryFilesystem()->createTemporaryFile('download_', null, $pi['extension']); $tempfile = $this->getTemporaryFilesystem()->createTemporaryFile('download_', null, $pi['extension']);
try { try {
$guzzle = new Guzzle($url); $guzzle = new Guzzle(['base_uri' => $url]);
$res = $guzzle->get("", [], ['save_to' => $tempfile])->send(); $res = $guzzle->get("", ['save_to' => $tempfile]);
} }
catch (\Exception $e) { catch (\Exception $e) {
throw new BadRequestHttpException(sprintf('Error "%s" downloading "%s"', $e->getMessage(), $url)); throw new BadRequestHttpException(sprintf('Error "%s" downloading "%s"', $e->getMessage(), $url));