restReqHeaderKey (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

ALL

Firmware version:

2.10.00


This function will read the name of a header field in a request.

By calling this multiple times with incrementing index, it is possible to list all the header fields in the request.

 

Input:

req : SYSHANDLE

A handle to the request.

 

idx : INT (Default 0)

The index of the header field to read the name of.

 

 

Output:

name : STRING

The name of the field.

 

 

Returns: INT

1


- Success

0


- Not supported

-1


- Invalid request

-2


- The header field was not found

 

Declaration:

FUNCTION restReqHeaderKey : INT;
VAR_INPUT
  req            : SYSHANDLE;
  idx            : INT;
  name           : ACCESS STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  rc        : INT;
  str, name : STRING;
  i         : INT;
  req       : SYSHANDLE;
END_VAR
BEGIN
  ...
 
  i:=0;
  // Get name of header
  rc := restReqHeaderKey(req:=req, idx:=i, name:=name);
  WHILE rc > 0 DO
    // Get value of header
    restReqHeaderGet(req:=req, name:=name, value:=str);
    DebugMsg(message:=" "+name+"="+str);
    i:=i+1;
    // Get name of next header
    rc := restReqHeaderKey(req:=req, idx:=i, name:=name);
  END_WHILE;
  ...
END;
END_PROGRAM;