Use $Restrict

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