Provides a simple, synchronous HTTP request interface for legacy JavaScript environments such as Rhino.
Core Features:
- Lightweight, synchronous HTTP client built on Java
HttpURLConnection. - Supports standard HTTP methods:
GET,POST,PUT, andDELETE. - Customizable headers, request body, and connection timeout.
- Returns a detailed response object with connection info, status, headers, and content.
- Simple error handling with
nullreturn andlastError()reporting.
Methods
(static) TCHttpRequest(url, method, headersopt, dataopt, timeoutopt) → {Object|null}
Sends an HTTP request and returns a detailed response object containing headers, content, status, and metadata.
This is a synchronous request function suitable for lightweight REST API calls or page content retrieval.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
url |
string | The website link string, for example: "https://example.com/". |
||
method |
string | Request method, default is GET. Common methods: GET, DELETE, PUT and POST. |
||
headers |
Object | string |
<optional> |
Request headers, default is {}. (headers="" is tolerated and treated as {}.) |
|
data |
string |
<optional> |
The request body (string), default is null. |
|
timeout |
number |
<optional> |
6000
|
Timeout in milliseconds, default is 6000. |
Returns:
Response object or null on failure.
- Type
- Object | null