From 3affec2950c6e08e307732546a434a465e4db510 Mon Sep 17 00:00:00 2001 From: AgalyaR Date: Thu, 20 Oct 2016 13:48:35 +0000 Subject: [PATCH] Doucmenation updated for REST_PUT --- modules/rest_client/doc/rest_client_admin.xml | 95 ++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/modules/rest_client/doc/rest_client_admin.xml b/modules/rest_client/doc/rest_client_admin.xml index 7db893eed8..78e9729cff 100644 --- a/modules/rest_client/doc/rest_client_admin.xml +++ b/modules/rest_client/doc/rest_client_admin.xml @@ -8,7 +8,7 @@ Overview The rest_client module provides a means of interacting - with an HTTP server by doing RESTful queries, such as GET and POST. + with an HTTP server by doing RESTful queries, such as GET,PUT and POST. @@ -281,6 +281,65 @@ if (!rest_post("http://myserver.org/register_user", "$fU", , "$var(body)", "$var exit; } ... + + + + +
+ + <function moreinfo="none">rest_put(url, send_body_pv, [send_ctype_pv], + recv_body_pv[, [recv_ctype_pv][, [retcode_pv]]]) + </function> + + + Issues an HTTP PUT request to the specified url. The request body will + be copied from the send_body_pv pseudo-variable. The MIME Content-Type + header for the request will be taken from send_ctype_pv (default is + "application/x-www-form-urlencoded") + + + The mandatory recv_body_pv pseudo-var will hold the body of the HTTP + response. + + + The optional recv_ctype_pv parameter will contain + the value of the "Content-Type" header of the response message. + + + The optional retcode_pv pseudo-var parameter can be given + in order to retrieve the HTTP status code of the response message. Since + the module based on libcurl, a 0 value + means no HTTP reply arrived at all. + + Possible parameter types + + + url, send_body_pv, send_type_pv - + String, pseudo-variable, or a String which includes pseudo-variables. + + + + recv_body_pv, recv_ctype_pv, retcode_pv - + pseudo-variables + + + + This function can be used from the startup, branch, failure, + request and timer routes. + + + <function moreinfo="none">rest_put</function> usage + +... +# Storing data using a RESTful service with an HTTP PUT request + +if (!rest_put("http://myserver.org/register_user", "$fU", , "$var(body)", "$var(ct)", "$var(rcode)")) { + xlog("Error code $var(rcode) in HTTP PUT!\n"); + send_reply("403", "PUT Forbidden"); + exit; +} +...
@@ -387,6 +446,40 @@ route [resume] } ...... } + + + + + +
+ + <function moreinfo="none">rest_put(url, send_body_pv, [send_ctype_pv], + recv_body_pv[, [recv_ctype_pv][, [retcode_pv]]]) + </function> + + + Sends a PUT HTTP request. This function behaves exactly the same as + (in terms of input, output and processing), + but in an asynchronous way. Script execution is suspended until the + entire content of the HTTP response if available. + + + <function moreinfo="none">async rest_put</function> usage + +route { + ... + async(rest_put("http://myserver.org/register_user", "$fU", , "$var(body)", "$var(ct)", "$var(rcode)"), resume); +} + +route [resume] +{ + if ($rc < 0) { + xlog("Error code $var(rcode) in HTTP PUT!\n"); + send_reply("403", "PUT Forbidden"); + exit; + } + ...... +}