feat(compat): sweep of components against the real core with strict diagnostics
This commit is contained in:
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
# Smoke del paquete http. Recibe BASE, PKG, RESULTS.
|
||||
set -u
|
||||
|
||||
check() {
|
||||
local comp="$1" path="$2" expect="$3" body
|
||||
if ! body="$(curl -fsS "$BASE$path" 2>/dev/null)"; then
|
||||
echo "$PKG:$comp|fail" >> "$RESULTS"; return
|
||||
fi
|
||||
if printf '%s' "$body" | grep -qF "$expect"; then
|
||||
echo "$PKG:$comp|ok" >> "$RESULTS"
|
||||
else
|
||||
echo " inesperado en $path: $(printf '%s' "$body" | head -c 200)" >&2
|
||||
echo "$PKG:$comp|fail" >> "$RESULTS"
|
||||
fi
|
||||
}
|
||||
|
||||
check curlRequest /compat/http/curl 'CURL_OK'
|
||||
check aria2 '/compat/http/load?class=Aria2' 'LOAD_OK:Libs\Aria2'
|
||||
check proxy '/compat/http/load?class=Proxy' 'LOAD_OK:Libs\Proxy'
|
||||
check compreFace '/compat/http/load?class=CompreFace' 'LOAD_OK:Libs\CompreFace'
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
// Router de compatibilidad del paquete http: curlRequest con flujo completo
|
||||
// (se llama a si mismo via el mismo servidor) y carga nivel 1 de los clientes
|
||||
// con servicio externo.
|
||||
|
||||
use Libs\Aria2;
|
||||
use Libs\CompreFace;
|
||||
use Libs\CurlRequest;
|
||||
use Libs\Proxy;
|
||||
use Libs\Router;
|
||||
|
||||
Router::get('/compat/http/echo', function () {
|
||||
echo 'ECHO:' . ($_GET['who'] ?? 'nadie');
|
||||
});
|
||||
|
||||
Router::get('/compat/http/curl', function () {
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$req = new CurlRequest();
|
||||
$req->get("http://$host/compat/http/echo?who=42");
|
||||
echo str_contains($req->body(), 'ECHO:42') ? 'CURL_OK' : 'CURL_FAIL:' . substr($req->body(), 0, 80);
|
||||
});
|
||||
|
||||
Router::get('/compat/http/load', function () {
|
||||
$class = 'Libs\\' . basename((string) ($_GET['class'] ?? ''));
|
||||
if (!class_exists($class)) {
|
||||
echo 'LOAD_MISSING';
|
||||
return;
|
||||
}
|
||||
$instance = match ($class) {
|
||||
'Libs\\Aria2' => new Aria2('http://127.0.0.1:6800/jsonrpc'),
|
||||
'Libs\\CompreFace' => new CompreFace('compat-key', 'http://127.0.0.1:18080'),
|
||||
default => new $class(),
|
||||
};
|
||||
echo 'LOAD_OK:' . get_class($instance);
|
||||
});
|
||||
Reference in New Issue
Block a user