Handle a refused connection as a result
ASPL 0.7.0 · Current release
Native only. Handle a refused connection as a result, with exact supplied sources, requirements, commands and outcomes.
On this page
Prepare the native host
Requires no listener on 127.0.0.1:9. A listener changes the expected result. The fixture uses an ephemeral closed local port.
Follow the deployment guide for certificates, CA selection, working directories and the complete upstream workflow.
Follow the HTTP guide and API reference. Keep the original filenames and the modules of the selected source variant. Save Arabic and English variants in separate directories. TLS inputs are supplied by the reader, with no bundled certificates or keys. No other data assets are required.
Arabic source
Execution: Native only · ASPL 0.7.0
- Native only. Published ASPL 0.7.0 on x86-64 Linux with glibc 2.34 or later. No input lines. Requires no listener on 127.0.0.1:9. A listener changes the expected result. The fixture uses an ephemeral closed local port.
Input: No input lines are required.
استورد أساسي::ويب.
دالة ابدأ_الرئيسية() -> ص64 {
دع طلب_صادر = ويب::أنشئ_طلب("GET", "http://127.0.0.1:9/")::قيمة.
دع رد = ويب::اطلب(طلب_صادر, ويب::خيارات_طلب()).
إذا رد::نجاح { أرجع 1. }
اطبع(رد::الخطأ::الرمز).
إذا رد::الخطأ::الرمز ليس يطابق "http.connect_failed" { أرجع 2. }
أرجع 0.
}
Follow the Linux instructions to run this example. Download the source to keep a copy.
Download رفض.لباتExpected outcomes
{
"native": {
"check": 0,
"status": 0,
"output": "http.connect_failed"
}
}English source
Execution: Native only · ASPL 0.7.0
- Native only. Published ASPL 0.7.0 on x86-64 Linux with glibc 2.34 or later. No input lines. Requires no listener on 127.0.0.1:9. A listener changes the expected result. The fixture uses an ephemeral closed local port.
Input: No input lines are required.
import core::http;
fn start_main() -> i64 {
let outbound = http::client_request("GET", "http://127.0.0.1:9/")::value;
let reply = http::request(outbound, http::client_options());
if reply::ok { return 1; }
print(reply::error::code);
if reply::error::code not matches "http.connect_failed" { return 2; }
return 0;
}
Follow the Linux instructions to run this example. Download the source to keep a copy.
Download refusal.asplExpected outcomes
{
"native": {
"check": 0,
"status": 0,
"output": "http.connect_failed"
}
}Commands and outcomes
ar:
aspl check ar/refusal.aspl
aspl run ar/refusal.aspl
aspl build -o http-refusal-ar-program ar/refusal.aspl
./http-refusal-ar-programen:
aspl check en/refusal.aspl
aspl run en/refusal.aspl
aspl build -o http-refusal-en-program en/refusal.aspl
./http-refusal-en-programRun these commands from the parent of the separate ar/en source directories. With the stated port closed, the program checks the failed result, prints http.connect_failed without a trailing newline and returns 0. It does not start a service. Expected outcome details above come from the catalog. See the HTTP collection.