$webinfo: Data Topics

The DATA, PATHINPUT, INPUT, and OUTPUT functions of $webinfo contain the data requested or loaded into server pages.

DATA

$webinfo("Data") is used only in dynamic server pages (DSPs). It is used by both webload and websave to pass data between the server backend and browser frontend of a DSP component.

PATHINPUT

$webinfo("PathInput") is used in both dynamic and static server pages (USPs) for RESTful URLs. For more information, see Uniface URL Format.

If the request was formatted as a RESTful URL, $webinfo("PathInput") returns Uniface list of input parameters.

You can process the list in ProcScript before returning a response using websave (for DSPs) or webgen (for USPs).

INPUT

$webinfo("Input") returns an associative list containing the input of the HTTP request, which is loaded into the server page by the webget or webload command. You can then process the list in ProcScript to extract the information needed to process the data and provide a response.

The content of the $webinfo("Input") depends on the HTTP request type:

POST

For HTTP POST requests, $webinfo("Input") returns the data from the component, with the content type of the page as the key. This has the format:

ContentType = BodyContent

  • ContentType must be a MIME text type, such as text/plain. Non-text MIME types are not supported.
  • BodyContent is the HTTP request body.

For example, if the Content-Type header is MIME type "text/plain", and body content is a JSON string in UTF-8, the $webinfo("Input") will be:

text/plain={ "id" : "n1", "name" : "foo" }

PUT

For HTTP PUT requests, $webinfo("Input") contains an associative list containing the contents of the query string (with querystring as the key), and the data from the component (with the content type of the page as the key). This has the format:

querystring=QueryParameterList;ContentType = BodyContent

  • QueryParameterList are query parameters in a format of Uniface sublist
  • ContentType must be a MIME text type, such as text/plain. Non-text MIME types are not supported.

    Note:  If URL encoding has been specified in the HTTP header, the content type will not be used as a key

  • BodyContent is the HTTP request body.

For example, consider a PUT request in which:

  • The URL is http://host:port/uniface/wrd/USP1?param1=v1&param2=v2
  • ContentType is text/plain
  • BodyContent is a JSON string in UTF-8.

The $webinfo("Input") will be

querystring=param1=v1!;param2=v2;text/plain={ "id" : "n1", "name" : "foo" }

GET

For HTTP GET requests, $webinfo("Input") returns the query string containing input parameters.

DELETE

For HTTP DELETE requests, $webinfo("Input") returns the query string, as with GET. The query string is used to identify the resource to delete.

OUTPUT

$webinfo("Output") contains the data sent to the web browser from a server page. Initially this is empty; it is populated by the webgen or websave commands.

You can supply an HTML page from ProcScript, or manipulate this to return data of MIME type text/* (such as text/plain, text/json, and so on). Non-text MIME types are not supported.

If a response needs to handle content type and data, you need to put Content-type=ContentType in the $webinfo("HttpResponseHeaders") and the content data into $webinfo("Output").

Related Topics