Use $Restrict

parent 373946de
......@@ -400,11 +400,7 @@ tus_server_recv(VRT_CTX, struct VPFX(tus_server) *tussrv,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
if (ctx->method != VCL_MET_RECV) {
VRT_fail(ctx, "%s.recv() must only be called from vcl_recv{}",
tussrv->vcl_name);
return (0);
}
assert(ctx->method == VCL_MET_RECV);
url = args->valid_url ? args->url : VRT_r_req_url(ctx);
......@@ -431,11 +427,7 @@ tus_server_deliver(VRT_CTX, struct VPFX(tus_server) *tussrv)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
if (ctx->method != VCL_MET_DELIVER) {
VRT_fail(ctx, "%s.deliver() must only be called "
"from vcl_deliver{}", tussrv->vcl_name);
return (0);
}
assert(ctx->method == VCL_MET_DELIVER);
r = tus_task_use(ctx, tussrv);
if (r == NULL)
......@@ -453,11 +445,7 @@ tus_server_synth(VRT_CTX, struct VPFX(tus_server) *tussrv)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
if (ctx->method != VCL_MET_SYNTH) {
VRT_fail(ctx, "%s.synth() must only be called "
"from vcl_synth{}", tussrv->vcl_name);
return (0);
}
assert(ctx->method == VCL_MET_SYNTH);
r = tus_task_use(ctx, tussrv);
if (r == NULL)
......@@ -476,11 +464,7 @@ VCL_BOOL tus_server_done(VRT_CTX, struct VPFX(tus_server) *tussrv,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
if ((ctx->method & VCL_MET_TASK_C) == 0) {
VRT_fail(ctx, "%s.done() must only be called "
"from client VCL subroutines", tussrv->vcl_name);
return (0);
}
AN(ctx->method & VCL_MET_TASK_C);
r = tus_task_use(ctx, tussrv);
if (r == NULL)
......@@ -501,11 +485,7 @@ tus_server_has_metadata(VRT_CTX, struct VPFX(tus_server) *tussrv,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
if ((ctx->method & VCL_MET_TASK_C) == 0) {
VRT_fail(ctx, "%s.has_metadata() must only be called "
"from client VCL subroutines", tussrv->vcl_name);
return (0);
}
AN(ctx->method & VCL_MET_TASK_C);
r = tus_task_use(ctx, tussrv);
if (r == NULL)
......@@ -525,11 +505,7 @@ tus_server_metadata(VRT_CTX, struct VPFX(tus_server) *tussrv,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
if ((ctx->method & VCL_MET_TASK_C) == 0) {
VRT_fail(ctx, "%s.metadata() must only be called "
"from client VCL subroutines", tussrv->vcl_name);
return (NULL);
}
AN(ctx->method & VCL_MET_TASK_C);
r = tus_task_use(ctx, tussrv);
if (r == NULL)
......
......@@ -191,18 +191,25 @@ Thus, the common call pattern is::
}
}
Must be called from ``vcl_recv {}``
$Restrict vcl_recv
$Method BOOL .deliver()
Generate a response to a tus request for which content was
stored. Must be called from ``vcl_deliver {}`` after `xserver.recv()`_
was called from ``vcl_recv {}``.
stored.
$Restrict vcl_deliver
Must be called after `xserver.recv()`_ was called from ``vcl_recv
{}``.
$Method BOOL .synth()
Generate a synthetic response to a tus request. Must be called from
``vcl_synth {}`` after `xserver.recv()`_ was called from ``vcl_recv {}``.
Generate a synthetic response to a tus request.
$Restrict vcl_synth
Must be called after `xserver.recv()`_ was called from ``vcl_recv {}``.
For the example above, the code would be::
......@@ -225,22 +232,28 @@ responses querying the object.
For any ``GET`` access, a 301 response with the *location* in the
``Location:`` response header is generated.
May only be called from client methods. For anything but final concat
or single (non-concat) uploads, this operation is a noop.
$Restrict client
For anything but final concat or single (non-concat) uploads, this
operation is a noop.
$Method BOOL .has_metadata(STRING key)
Return true if *key* is present in the metadata.
Only available if vmod_blob is available (see `Hashes` _) and on the
client side after `xserver.recv()`_ was called from ``vcl_recv {}``.
$Restrict client
Only available if vmod_blob is available (see `Hashes` _) and after
`xserver.recv()`_ was called from ``vcl_recv {}``.
$Method BLOB .metadata(STRING key)
Extract *key* from metadata and return the corresponding value decoded.
Only available if vmod_blob is available (see `Hashes` _) and on the
client side after `xserver.recv()`_ was called from ``vcl_recv {}``.
$Restrict client
Only available if vmod_blob is available (see `Hashes` _) and after
`xserver.recv()`_ was called from ``vcl_recv {}``.
$Method VOID .sync()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment