Dire perche' una richiesta fallisce, e annunciare HTTP/1.1 con ALPN

engine_session_fetch non riportava il motivo: restituiva NULL e il guscio
mostrava "richiesta fallita", che non serve a nessuno. Ora c'e' un parametro
d'errore e il guscio lo scrive nel log insieme all'indirizzo.

TLS annuncia http/1.1 con ALPN: alcuni server e CDN rifiutano chi non negozia
nulla, ed era una differenza silenziosa rispetto ai browser veri.
This commit is contained in:
Carlo Baratto committed 2026-11-12 20:51:48 +01:00
1 parent 4d0e55bc16
commit befb3f289f
6 files changed
+54 -11

No files matched your search

+25 -2
View File
@@ -615,11 +615,18 @@ pub extern "C" fn engine_session_fetch(
metodo: *const c_char,
corpo: *const c_char,
status: *mut std::os::raw::c_int,
error: *mut *mut c_char,
) -> *mut c_char {
if !status.is_null() {
unsafe { *status = 0 };
}
if !error.is_null() {
unsafe { *error = std::ptr::null_mut() };
}
if sessione.is_null() || url.is_null() {
if !error.is_null() {
unsafe { *error = cstring_errore("sessione o indirizzo nullo") };
}
return std::ptr::null_mut();
}
let s = unsafe { &*sessione };
@@ -643,10 +650,26 @@ pub extern "C" fn engine_session_fetch(
Ok(testo) => CString::new(testo.replace('\0', " "))
.map(|c| c.into_raw())
.unwrap_or(std::ptr::null_mut()),
Err(_) => std::ptr::null_mut(),
Err(messaggio) => {
if !error.is_null() {
unsafe { *error = cstring_errore(messaggio) };
}
std::ptr::null_mut()
}
}
}
_ => std::ptr::null_mut(),
Ok(Err(messaggio)) => {
if !error.is_null() {
unsafe { *error = cstring_errore(messaggio) };
}
std::ptr::null_mut()
}
Err(_) => {
if !error.is_null() {
unsafe { *error = cstring_errore("errore interno durante la richiesta") };
}
std::ptr::null_mut()
}
}
}
+3 -1
View File
@@ -410,13 +410,15 @@ fn apri_tls(
let radici = rustls::RootCertStore {
roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(),
};
let configurazione = rustls::ClientConfig::builder_with_provider(std::sync::Arc::new(
let mut configurazione = rustls::ClientConfig::builder_with_provider(std::sync::Arc::new(
rustls::crypto::ring::default_provider(),
))
.with_safe_default_protocol_versions()
.map_err(|e| format!("versioni TLS: {}", e))?
.with_root_certificates(radici)
.with_no_client_auth();
// annunciare HTTP/1.1: alcuni server (e CDN) rifiutano chi non negozia nulla
configurazione.alpn_protocols = vec![b"http/1.1".to_vec()];
let nome = rustls::pki_types::ServerName::try_from(host.to_string())
.map_err(|_| format!("nome del server non valido: {}", host))?;