Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\HttpClient;
|
||||
|
||||
use App\Framework\Http\HeaderManipulator;
|
||||
@@ -12,16 +14,17 @@ use CurlHandle;
|
||||
final readonly class CurlHttpClient implements HttpClient
|
||||
{
|
||||
public function __construct(
|
||||
private CurlResponseParser $responseParser = new CurlResponseParser,
|
||||
private AuthenticationHandler $authenticationHandler = new AuthenticationHandler,
|
||||
private CurlRequestBuilder $requestBuilder = new CurlRequestBuilder,
|
||||
){}
|
||||
private CurlResponseParser $responseParser = new CurlResponseParser(),
|
||||
private AuthenticationHandler $authenticationHandler = new AuthenticationHandler(),
|
||||
private CurlRequestBuilder $requestBuilder = new CurlRequestBuilder(),
|
||||
) {
|
||||
}
|
||||
|
||||
public function initializeCurl(): \CurlHandle
|
||||
{
|
||||
$curlHandle = curl_init();
|
||||
|
||||
if($curlHandle === false) {
|
||||
if ($curlHandle === false) {
|
||||
throw new CurlNotInitialized();
|
||||
}
|
||||
|
||||
@@ -32,18 +35,18 @@ final readonly class CurlHttpClient implements HttpClient
|
||||
{
|
||||
$options = $this->requestBuilder->buildOptions($request);
|
||||
|
||||
if($request->options->auth !== []) {
|
||||
if ($request->options->auth !== []) {
|
||||
|
||||
$authResult = $this->authenticationHandler->configure($request->options->auth, $request->headers);
|
||||
|
||||
if($authResult->headers !== $request->headers) {
|
||||
if ($authResult->headers !== $request->headers) {
|
||||
$updatedRequest = $request->with(['headers' => $authResult->headers]);
|
||||
$options = $this->requestBuilder->buildOptions($updatedRequest);
|
||||
} else {
|
||||
$options = $this->requestBuilder->buildOptions($request);
|
||||
}
|
||||
|
||||
if(!empty($authResult->curlOptions)) {
|
||||
if (! empty($authResult->curlOptions)) {
|
||||
$options = array_replace($options, $authResult->curlOptions);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +58,7 @@ final readonly class CurlHttpClient implements HttpClient
|
||||
{
|
||||
$rawResponse = curl_exec($ch);
|
||||
|
||||
if($rawResponse === false) {
|
||||
if ($rawResponse === false) {
|
||||
throw new CurlExecutionFailed(curl_error($ch), curl_errno($ch));
|
||||
}
|
||||
|
||||
@@ -81,71 +84,71 @@ final readonly class CurlHttpClient implements HttpClient
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// URL mit Query-Parametern verarbeiten
|
||||
$url = $request->url;
|
||||
if (!empty($request->options->query)) {
|
||||
$separator = str_contains($url, '?') ? '&' : '?';
|
||||
$url .= $separator . http_build_query($request->options->query);
|
||||
}
|
||||
/*
|
||||
// URL mit Query-Parametern verarbeiten
|
||||
$url = $request->url;
|
||||
if (!empty($request->options->query)) {
|
||||
$separator = str_contains($url, '?') ? '&' : '?';
|
||||
$url .= $separator . http_build_query($request->options->query);
|
||||
}
|
||||
|
||||
$options = [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_CUSTOMREQUEST => $request->method->value,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => true,
|
||||
CURLOPT_TIMEOUT => $request->options->timeout,
|
||||
CURLOPT_CONNECTTIMEOUT => $request->options->connectTimeout,
|
||||
CURLOPT_FOLLOWLOCATION => $request->options->followRedirects,
|
||||
CURLOPT_MAXREDIRS => $request->options->maxRedirects,
|
||||
CURLOPT_SSL_VERIFYPEER => $request->options->verifySsl,
|
||||
CURLOPT_SSL_VERIFYHOST => $request->options->verifySsl ? 2 : 0,
|
||||
];
|
||||
$options = [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_CUSTOMREQUEST => $request->method->value,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => true,
|
||||
CURLOPT_TIMEOUT => $request->options->timeout,
|
||||
CURLOPT_CONNECTTIMEOUT => $request->options->connectTimeout,
|
||||
CURLOPT_FOLLOWLOCATION => $request->options->followRedirects,
|
||||
CURLOPT_MAXREDIRS => $request->options->maxRedirects,
|
||||
CURLOPT_SSL_VERIFYPEER => $request->options->verifySsl,
|
||||
CURLOPT_SSL_VERIFYHOST => $request->options->verifySsl ? 2 : 0,
|
||||
];
|
||||
|
||||
// User-Agent setzen wenn vorhanden
|
||||
if ($request->options->userAgent !== null) {
|
||||
$options[CURLOPT_USERAGENT] = $request->options->userAgent;
|
||||
}
|
||||
// User-Agent setzen wenn vorhanden
|
||||
if ($request->options->userAgent !== null) {
|
||||
$options[CURLOPT_USERAGENT] = $request->options->userAgent;
|
||||
}
|
||||
|
||||
// Proxy setzen wenn vorhanden
|
||||
if ($request->options->proxy !== null) {
|
||||
$options[CURLOPT_PROXY] = $request->options->proxy;
|
||||
}
|
||||
// Proxy setzen wenn vorhanden
|
||||
if ($request->options->proxy !== null) {
|
||||
$options[CURLOPT_PROXY] = $request->options->proxy;
|
||||
}
|
||||
|
||||
// Authentifizierung einrichten
|
||||
if ($request->options->auth !== null) {
|
||||
$this->setupAuthentication($ch, $request->options->auth, $request->headers);
|
||||
}
|
||||
// Authentifizierung einrichten
|
||||
if ($request->options->auth !== null) {
|
||||
$this->setupAuthentication($ch, $request->options->auth, $request->headers);
|
||||
}
|
||||
|
||||
// Request-Body verarbeiten
|
||||
if ($request->body !== '') {
|
||||
$options[CURLOPT_POSTFIELDS] = $request->body;
|
||||
}
|
||||
// Request-Body verarbeiten
|
||||
if ($request->body !== '') {
|
||||
$options[CURLOPT_POSTFIELDS] = $request->body;
|
||||
}
|
||||
|
||||
// Headers formatieren und setzen
|
||||
if (count($request->headers->all()) > 0) {
|
||||
$options[CURLOPT_HTTPHEADER] = HeaderManipulator::formatForCurl($request->headers);
|
||||
}
|
||||
// Headers formatieren und setzen
|
||||
if (count($request->headers->all()) > 0) {
|
||||
$options[CURLOPT_HTTPHEADER] = HeaderManipulator::formatForCurl($request->headers);
|
||||
}
|
||||
|
||||
curl_setopt_array($ch, $options);
|
||||
curl_setopt_array($ch, $options);
|
||||
|
||||
$raw = curl_exec($ch);
|
||||
$raw = curl_exec($ch);
|
||||
|
||||
if ($raw === false) {
|
||||
throw new CurlExecutionFailed(curl_error($ch), curl_errno($ch));
|
||||
}
|
||||
if ($raw === false) {
|
||||
throw new CurlExecutionFailed(curl_error($ch), curl_errno($ch));
|
||||
}
|
||||
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$headersRaw = substr($raw, 0, $headerSize);
|
||||
$body = substr($raw, $headerSize);
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$headersRaw = substr($raw, 0, $headerSize);
|
||||
$body = substr($raw, $headerSize);
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
$headers = HeaderManipulator::fromString($headersRaw);
|
||||
$headers = HeaderManipulator::fromString($headersRaw);
|
||||
|
||||
return new ClientResponse(
|
||||
status: Status::from($status),
|
||||
headers: $headers,
|
||||
body: $body
|
||||
);*/
|
||||
return new ClientResponse(
|
||||
status: Status::from($status),
|
||||
headers: $headers,
|
||||
body: $body
|
||||
);*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user