|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > HTP. - Command > !HTP-General - General HTTP operations and utilities > !Request-Management - Commands for preparing, executing, and inspecting HTTP requests > HTP. - HTTP Operations |
SPR Script Language
HTP.GetW
Gets the last decoded text result from an HTTP request. Alias: HTP.GetText
Intention
After making an HTTP request with a command like HTP.ReqShort, the server's response is often text (like JSON or HTML). The HTP.GetW command retrieves this text for you. It accesses the library's internal Unicode (WSTRING) result, converts it to a standard UTF-8 STRING, and provides it to your script.
This is the primary command to use when you expect a human-readable text response from an API. For raw, un-decoded binary data (like an image file), use HTP.GetS instead.
Syntax
HTP.GetW[|$$RET]
HTP.GetText[|$$RET]
Parameter Explanation
P1 - $$RET - (Variable, String, Optional)
The variable where the decoded UTF-8 text response will be stored. If omitted, the result is placed on the top-of-stack (TOS).
Examples
'***********************************
' HTP.GetW - Sample 1: Get a text response after a request
'***********************************
VAR.$$URL=https://httpbin.org/html
HTP.ReqShort|GET|$$URL|||$$DUM
JIV.$$TOS!200|Lab_failed
' Get the decoded HTML content
HTP.GetW|$$RES
MBX.Response:|$$RES
END.
Remarks
- The name GetW refers to the internal source of the data (a WSTRING). The command always provides a standard UTF-8 STRING to the script for maximum compatibility.
- Use this command after HTP.ReqShort or after manually decoding a raw response with HTP.FromUTF8.
- HTP.GetText is a direct alias for this command.
See also:
• HTP.GetS