From 7a36b967901848879ad5e246e4776b403b128c09 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 14 Apr 2016 09:33:20 +0100 Subject: [PATCH] Update from SimGear API change - support new HTTP cancellation API --- src/Scripting/NasalHTTP.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Scripting/NasalHTTP.cxx b/src/Scripting/NasalHTTP.cxx index 7556db721..15c76ed34 100644 --- a/src/Scripting/NasalHTTP.cxx +++ b/src/Scripting/NasalHTTP.cxx @@ -77,6 +77,15 @@ static naRef f_http_load(const nasal::CallContext& ctx) return ctx.to_nasal( requireHTTPClient(ctx.c).client()->load(url) ); } +static naRef f_request_abort(simgear::HTTP::Request&, const nasal::CallContext& ctx) +{ + // we need a request_ptr for cancel, not a reference. So extract + // the me object from the context directly. + simgear::HTTP::Request_ptr req = ctx.from_nasal(ctx.me); + requireHTTPClient(ctx.c).client()->cancelRequest(req); + return naNil(); +} + //------------------------------------------------------------------------------ naRef initNasalHTTP(naRef globals, naContext c) { @@ -93,7 +102,7 @@ naRef initNasalHTTP(naRef globals, naContext c) .member("status", &Request::responseCode) .member("reason", &Request::responseReason) .member("readyState", &Request::readyState) - .method("abort", static_cast(&Request::abort)) + .method("abort", f_request_abort) .method("done", static_cast(&Request::done)) .method("fail", static_cast(&Request::fail)) .method("always", static_cast(&Request::always));