HTTP/2 (src/http2.rs): preface, SETTINGS, HEADERS/CONTINUATION, DATA, WINDOW_UPDATE, PING, RST_STREAM, GOAWAY; HPACK con tabella statica, dinamica e Huffman. Le tabelle sono generate dalla RFC 7541 (src/hpack_tabelle.rs) e validate sui suoi esempi, non trascritte a mano. Ambito dichiarato: una richiesta per connessione, senza multiplexing ne' push. Proxy (src/net.rs): http_proxy/https_proxy/all_proxy/no_proxy, tunnel CONNECT per https, Proxy-Authorization con base64. Provato con un finto proxy locale: forma assoluta per http, CONNECT per https, rifiuto del tunnel riportato. multipart/form-data e text/plain oltre a urlencoded (src/invio.rs): il corpo viaggia col tipo dichiarato, e il test verifica che il confine annunciato nell'intestazione separi davvero le parti che il server riceve. Processo di rete separato (src/bin/mosaic-net.rs): IPC a lunghezza prefissata su stdin/stdout, corpo in base64; il servizio tiene cookie e cache. Il desktop lo usa con --rete-esterna. Sul telefono la rete resta nel processo: un'app sandboxata non avvia figli in modo affidabile. Due difetti trovati dai test e non dalla lettura: - intero() in HPACK mascherava con AND invece di comporre con OR: ogni lunghezza di stringa finiva a zero. Era il GOAWAY dei siti veri. - rustls stringe la mano pigramente: alpn_protocol() era vuoto e si finiva sempre in HTTP/1.1 senza dirlo. Ora l'handshake e' forzato e MOSAIC_DEBUG lo stampa.
71 lines
2.4 KiB
Bash
71 lines
2.4 KiB
Bash
#!/bin/sh
|
|
# Verifica della rete su pagine vere. Non fa parte della CI predefinita: esce in
|
|
# internet e dipende da servizi di terzi. Si lancia a mano o con MOSAIC_NET=1.
|
|
set -eu
|
|
|
|
RADICE=$(cd "$(dirname "$0")/.." && pwd)
|
|
RENDER="$RADICE/target/release/render"
|
|
FONT=${FONT:-/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf}
|
|
USCITA=${TMPDIR:-/tmp}
|
|
|
|
if [ ! -x "$RENDER" ]; then
|
|
echo "serve prima: cargo build --release"
|
|
exit 1
|
|
fi
|
|
|
|
fallisci=0
|
|
|
|
prova() {
|
|
descrizione=$1
|
|
url=$2
|
|
atteso=$3
|
|
if "$RENDER" --url "$url" --font "$FONT" --out "$USCITA/net-check.png" \
|
|
--size 640x480 --scale 1 >"$USCITA/net-check.json" 2>"$USCITA/net-check.err"; then
|
|
righe=$(sed -n 's/.*"lines":\([0-9]*\).*/\1/p' "$USCITA/net-check.json")
|
|
nodi=$(sed -n 's/.*"nodes":\([0-9]*\).*/\1/p' "$USCITA/net-check.json")
|
|
if [ "${nodi:-0}" -ge "$atteso" ]; then
|
|
echo "ok $descrizione (nodi $nodi, righe ${righe:-0})"
|
|
else
|
|
echo "FAIL $descrizione: nodi $nodi, attesi almeno $atteso"
|
|
fallisci=1
|
|
fi
|
|
else
|
|
echo "FAIL $descrizione: $(tail -1 "$USCITA/net-check.err")"
|
|
fallisci=1
|
|
fi
|
|
}
|
|
|
|
# HTTPS con certificato valido, corpo con Content-Length
|
|
prova "https example.com" "https://example.com/" 3
|
|
# il server di prova locale serve in chunked; qui si controlla che un 404 non blocchi
|
|
prova "http con reindirizzamento a https" "http://example.com/" 3
|
|
|
|
# un errore di rete deve uscire con codice 1 e un messaggio, non con una pagina vuota
|
|
if "$RENDER" --url "http://127.0.0.1:1/" --font "$FONT" --out "$USCITA/net-check.png" \
|
|
--size 320x200 >/dev/null 2>"$USCITA/net-check.err"; then
|
|
echo "FAIL connessione rifiutata: doveva fallire"
|
|
fallisci=1
|
|
else
|
|
if grep -q "connessione" "$USCITA/net-check.err"; then
|
|
echo "ok connessione rifiutata: messaggio esplicito"
|
|
else
|
|
echo "FAIL connessione rifiutata: messaggio inatteso"
|
|
fallisci=1
|
|
fi
|
|
fi
|
|
|
|
# 4. HTTP/2: il server deve negoziare h2 e la pagina deve arrivare
|
|
if MOSAIC_DEBUG=1 "$RENDER" --url https://example.com/ --font "$FONT" \
|
|
--out "$USCITA/h2.png" --size 320x240 > "$USCITA/h2.out" 2> "$USCITA/h2.err"; then
|
|
if grep -q "richiesta in HTTP/2" "$USCITA/h2.err"; then
|
|
echo "ok HTTP/2: negoziato con example.com"
|
|
else
|
|
echo "warn HTTP/2 non negoziato (il server può non offrirlo)"
|
|
fi
|
|
else
|
|
echo "FAIL HTTP/2: la pagina non è arrivata"
|
|
fallisci=1
|
|
fi
|
|
|
|
exit $fallisci
|