From: James Turner Date: Thu, 14 Apr 2016 08:33:20 +0000 (+0100) Subject: Update from SimGear API change X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7a36b967901848879ad5e246e4776b403b128c09;p=flightgear.git Update from SimGear API change - support new HTTP cancellation API --- 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));