From ce09c320d32728dd9c5eb0d6b4ab9f4683242cbc Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sun, 27 Oct 2013 23:39:52 +0100 Subject: [PATCH] HTTP: Rename urlretrieve/urlload to save/load. --- src/Scripting/NasalHTTP.cxx | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Scripting/NasalHTTP.cxx b/src/Scripting/NasalHTTP.cxx index fb29bc924..344a87688 100644 --- a/src/Scripting/NasalHTTP.cxx +++ b/src/Scripting/NasalHTTP.cxx @@ -48,10 +48,12 @@ FGHTTPClient& requireHTTPClient(naContext c) } /** - * urlretrieve(url, filename) + * http.save(url, filename) */ -static naRef f_urlretrieve(const nasal::CallContext& ctx) +static naRef f_http_save(const nasal::CallContext& ctx) { + const std::string url = ctx.requireArg(0); + // Check for write access to target file const std::string filename = ctx.requireArg(1); const std::string validated_path = fgValidatePath(filename, true); @@ -63,30 +65,20 @@ static naRef f_urlretrieve(const nasal::CallContext& ctx) return ctx.to_nasal ( - requireHTTPClient(ctx.c).client() - ->urlretrieve - ( - ctx.requireArg(0), // url - validated_path // filename - ) + requireHTTPClient(ctx.c).client()->save(url, validated_path) ); } /** - * urlload(url) + * http.load(url) */ -static naRef f_urlload(const nasal::CallContext& ctx) +static naRef f_http_load(const nasal::CallContext& ctx) { - return ctx.to_nasal - ( - requireHTTPClient(ctx.c).client() - ->urlload - ( - ctx.requireArg(0) // url - ) - ); + const std::string url = ctx.requireArg(0); + return ctx.to_nasal( requireHTTPClient(ctx.c).client()->load(url) ); } +//------------------------------------------------------------------------------ naRef initNasalHTTP(naRef globals, naContext c) { using simgear::HTTP::Request; @@ -118,8 +110,8 @@ naRef initNasalHTTP(naRef globals, naContext c) nasal::Hash globals_module(globals, c), http = globals_module.createHash("http"); - http.set("urlretrieve", f_urlretrieve); - http.set("urlload", f_urlload); + http.set("save", f_http_save); + http.set("load", f_http_load); return naNil(); }