HTP. - HTTP Operations

<< 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

HTP.GetS

Previous Top Next


SPR Script Language

 

HTP.GetS

Gets the last raw STRING result from an HTTP operation. Also available as HTP.GetRaw.

 

Intention

 

The HTP.GetS command retrieves the raw, unmodified byte string from the body of the last HTTP response. This is essential when working with binary data (like images or zip files) or when you need to perform custom decoding on a text response. It gives you the exact data the server sent, without any character encoding translation.

 

Use this command after HTP.Request to access the raw response. For decoded text (UTF-8), use HTP.GetW instead.

 

Syntax

 

HTP.GetS[|$$RET]

 

Parameter Explanation

 

P1 - $$RET - (Variable, String, Optional)

The variable where the raw result string will be stored. If omitted, the result is placed on the top-of-stack (TOS), but using a named variable is recommended.

 

Examples

 

'***********************************

' HTP.GetS - Sample 1: Get raw bytes from an endpoint

'***********************************

VAR.$$URL=https://httpbin.org/bytes/128

 

' HTP.Request returns the raw body in $$RAW and status on TOS

HTP.Request|GET|$$URL|||||$$RAW

JIV.$$TOS!200|Lab_failed

 

' HTP.GetS can be used to retrieve the same raw data again

HTP.GetS|$$VAL

JIV.$$VAL!$$RAW|Lab_failed

 

MBX.Success:|Retrieved 128 raw bytes successfully.

END.

 

 

Remarks

 

- This command retrieves the result stored by the most recent call to HTP.Request.

- The result is a raw byte string. For text content, it is highly recommended to use HTP.GetW instead, which returns the decoded UTF-8 text.

- This command is aliased as HTP.GetRaw.

 

See also:

 

HTP.GetW

HTP.Request