HTTP/2, proxy, multipart e processo di rete separato (M2.6b)
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.
This commit is contained in:
1 parent
befb3f289f
commit
cc449a548d
21 files changed
+2222
-33
No files matched your search
@@ -188,11 +188,70 @@ void EngineView::clicCss(qreal cssX, qreal cssY)
|
||||
}
|
||||
const int gestori = engine_doc_click(m_doc, float(cssX), float(cssY));
|
||||
qDebug() << "mosaic: click js" << cssX << cssY << "gestori" << gestori;
|
||||
|
||||
// pulsante di invio senza preventDefault: il formulario va mandato davvero
|
||||
if (eseguiInvio()) {
|
||||
return; // la risposta sostituisce la pagina e la ridisegna
|
||||
}
|
||||
if (gestori > 0) {
|
||||
rerender();
|
||||
}
|
||||
}
|
||||
|
||||
/// Esegue l'invio del formulario che il motore ha lasciato in attesa, se c'è.
|
||||
/// Restituisce vero se la pagina è stata sostituita dalla risposta.
|
||||
bool EngineView::eseguiInvio()
|
||||
{
|
||||
if (!m_doc || !m_sessione) {
|
||||
return false;
|
||||
}
|
||||
const QByteArray stato = stateJson().toUtf8();
|
||||
char *json = engine_doc_invio_json(m_doc, stato.constData());
|
||||
if (!json) {
|
||||
return false;
|
||||
}
|
||||
const QJsonObject richiesta = QJsonDocument::fromJson(QByteArray(json)).object();
|
||||
engine_string_free(json);
|
||||
if (richiesta.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString metodo = richiesta.value(QStringLiteral("metodo")).toString(QStringLiteral("GET"));
|
||||
const QString url = richiesta.value(QStringLiteral("url")).toString();
|
||||
const QString corpo = richiesta.value(QStringLiteral("corpo")).toString();
|
||||
const QString tipo = richiesta.value(QStringLiteral("tipo")).toString();
|
||||
if (url.isEmpty()) {
|
||||
setError(QStringLiteral("invio senza indirizzo"));
|
||||
return false;
|
||||
}
|
||||
qDebug() << "mosaic: invio" << metodo << url;
|
||||
|
||||
int statoHttp = 0;
|
||||
char *errore = nullptr;
|
||||
char *testo = engine_session_fetch(m_sessione.get(),
|
||||
url.toUtf8().constData(),
|
||||
metodo.toUtf8().constData(),
|
||||
corpo.toUtf8().constData(),
|
||||
tipo.toUtf8().constData(),
|
||||
&statoHttp,
|
||||
&errore);
|
||||
if (errore) {
|
||||
setError(QStringLiteral("invio fallito — %1").arg(QString::fromUtf8(errore)));
|
||||
engine_string_free(errore);
|
||||
}
|
||||
if (!testo) {
|
||||
return false;
|
||||
}
|
||||
m_html = QString::fromUtf8(testo);
|
||||
engine_string_free(testo);
|
||||
m_url = url;
|
||||
creaDocumento();
|
||||
rerender();
|
||||
emit htmlChanged();
|
||||
emit urlChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Fa avanzare i timer della pagina. Restituisce vero se qualcosa è cambiato.
|
||||
bool EngineView::serviFetch()
|
||||
{
|
||||
@@ -235,6 +294,7 @@ bool EngineView::serviFetch()
|
||||
url.constData(),
|
||||
metodo.toUtf8().constData(),
|
||||
corpo.toUtf8().constData(),
|
||||
"",
|
||||
&stato,
|
||||
&messaggio_fetch);
|
||||
const QByteArray dati(corpo_risposta ? corpo_risposta : "");
|
||||
@@ -555,8 +615,8 @@ void EngineView::loadUrl(const QString &url)
|
||||
int stato = 0;
|
||||
char *messaggio = nullptr;
|
||||
// con la sessione: i cookie ricevuti restano per le richieste successive
|
||||
char *testo = engine_session_fetch(sessione.get(), u.c_str(), "GET", "", &stato,
|
||||
&messaggio);
|
||||
char *testo = engine_session_fetch(sessione.get(), u.c_str(), "GET", "", "",
|
||||
&stato, &messaggio);
|
||||
if (testo) {
|
||||
html = testo;
|
||||
engine_string_free(testo);
|
||||
|
||||
Reference in new issue
Block a user