HTTP: Rename urlretrieve/urlload to save/load.
This commit is contained in:
parent
cf270bde22
commit
ce09c320d3
1 changed files with 12 additions and 20 deletions
|
@ -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<std::string>(0);
|
||||||
|
|
||||||
// Check for write access to target file
|
// Check for write access to target file
|
||||||
const std::string filename = ctx.requireArg<std::string>(1);
|
const std::string filename = ctx.requireArg<std::string>(1);
|
||||||
const std::string validated_path = fgValidatePath(filename, true);
|
const std::string validated_path = fgValidatePath(filename, true);
|
||||||
|
@ -63,30 +65,20 @@ static naRef f_urlretrieve(const nasal::CallContext& ctx)
|
||||||
|
|
||||||
return ctx.to_nasal
|
return ctx.to_nasal
|
||||||
(
|
(
|
||||||
requireHTTPClient(ctx.c).client()
|
requireHTTPClient(ctx.c).client()->save(url, validated_path)
|
||||||
->urlretrieve
|
|
||||||
(
|
|
||||||
ctx.requireArg<std::string>(0), // url
|
|
||||||
validated_path // filename
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
const std::string url = ctx.requireArg<std::string>(0);
|
||||||
(
|
return ctx.to_nasal( requireHTTPClient(ctx.c).client()->load(url) );
|
||||||
requireHTTPClient(ctx.c).client()
|
|
||||||
->urlload
|
|
||||||
(
|
|
||||||
ctx.requireArg<std::string>(0) // url
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
naRef initNasalHTTP(naRef globals, naContext c)
|
naRef initNasalHTTP(naRef globals, naContext c)
|
||||||
{
|
{
|
||||||
using simgear::HTTP::Request;
|
using simgear::HTTP::Request;
|
||||||
|
@ -118,8 +110,8 @@ naRef initNasalHTTP(naRef globals, naContext c)
|
||||||
nasal::Hash globals_module(globals, c),
|
nasal::Hash globals_module(globals, c),
|
||||||
http = globals_module.createHash("http");
|
http = globals_module.createHash("http");
|
||||||
|
|
||||||
http.set("urlretrieve", f_urlretrieve);
|
http.set("save", f_http_save);
|
||||||
http.set("urlload", f_urlload);
|
http.set("load", f_http_load);
|
||||||
|
|
||||||
return naNil();
|
return naNil();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue