HTP. - HTTP Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network >

HTP. - HTTP Operations

HTP. Command Overview

Previous Top Next


SPR Script Language

 

HTP. Command Overview

Lists all available HTP. commands for HTTP operations.

 

Intention

 

The HTP. namespace in SPR provides a suite of commands for performing HTTP operations, such as sending requests, managing errors, setting timeouts, and configuring proxies. This overview lists all available HTP. commands, offering a quick reference for their purposes and linking to detailed documentation for each.

 

It’s your robot’s HTTP toolbox—everything you need to connect, debug, and manage web requests in one place.

 

Command List

 

Command

Description

HTP.ClrErr

Clear the last error state, optionally clearing history.

HTP.ConvCont

Convert response content based on Content-Type (simplified).

HTP.GetErr

Return the last error message as text.

HTP.GetErrText

Return the error message text for a given error code.

HTP.GetReq

Normalize and return the HTTP request type.

HTP.GetUA

Return the User-Agent string for a given index.

HTP.InitHdr

Initialize HTTP headers with API key and content type.

HTP.MCPExec

Execute a specified action with a value on the MCP server, returning the result code.

MCP.End

Send an "END" signal to terminate the MCP server, returning success status.

MCP.Init

Initialize the MCP server, optionally with a config file.

HTP.MCPPerm

Request permission from the MCP server with a request string, optional timeout, returning result and response.

HTP.MCPSignal

Send a signal to the MCP server with a type and optional data, returning the queue index.

MCP.Start

Start the MCP server in a separate thread, initializing it with an optional config file if not already initialized, returning the thread handle.

MCP.Stop

Shut down the MCP server and clean up resources.

HTP.ReqShort

Perform a simplified HTTP request using static defaults.

HTP.Request

Perform a full HTTP request with all parameters.

HTP.SetConTO

Set the connection timeout value in milliseconds.

HTP.SetDebug

Switch Debug for Connection on.

HTP.SetDef

Set static defaults.

HTP.SetHdr

Construct Header from Parameter.

HTP.SetProxy

Set the proxy server name and bypass list.

HTP.SetRcvTO

Set the receive timeout value in milliseconds.

HTP.SetResTO

Set the DNS resolve timeout value in milliseconds.

HTP.SetSndTO

Set the send timeout value in milliseconds.

HTP.SetTO

Set the overall timeout value in milliseconds.

HTP.ToUTF8

Convert String to UTF8.

HTP.UseProxy

Enable or disable proxy usage.

 

 

clip1083

In this Sample we access "LM Studio" a Local running LLM. You can see how we can preserve the Emojis using PSJ.Get Last ResultW and CLB.Set Uni Text.

 

 

Sample Code

 

' This code will access LM-Studio, a local running LLM.

$$URB=http://localhost:1234/

$$REA=api/v0/completions

VAV.$$URL=$$URB$$REA

HTP.InitHdr|-|-

 ' Add if token is needed

HTP.AddHdr|Authorization|Bearer your-valid-token-here

$$JSO={"model": "gemma-3-27b-it", "prompt": "Send me some nice emojis."}

$$CMD=POST

HTP.Setdebug|0

HTP.SetTO|36000

HTP.Request|$$CMD|$$URL|$$JSO|-|0|0|0|$$RET

PSJ.Parse|-|$$DOC

$$PAT=choices[0].text

PSJ.GetStr|$$DOC|$$PAT|$$TEX

MBX.$$TEX

PSJ.GetLastResultW|$$TEA

CLB.Set Unitext|$$TEA

' Please paste the Clipboard now into a Page like Twitter/X etc. and check the Emojis.

PSJ.FreeAll

ENR.

 

 

Remarks

 

- Commands are designed for use in SPR scripts to manage HTTP interactions.

- Each command links to a detailed help page for syntax and examples.

- Use HTP.SetDebug to enable verbose output for troubleshooting.

 

Limitations

 

- Some commands may require prior configuration (e.g., proxy settings).

 

See also:

 

HTP.SetDebug

HTP.Request