The HTTP module is:
org.densy.scriptify.http.script.module.HttpScriptModuleModule name:
http
script.getModuleManager().addModule(new HttpScriptModule());With restricted Java member access:
script.getModuleManager().setScriptAccess(ScriptAccess.EXPLICIT);HttpRequest, HttpMethod, and OutputType are annotated for explicit access.
| Export | Type | Description |
|---|---|---|
HttpRequest |
Java class | Request object. |
HttpMethod |
Java enum | HTTP method enum. |
OutputType |
Java enum | Response output type enum. |
createHttpRequest |
Scriptify function | Factory function for HttpRequest. |
Supported values:
GETPUTPOSTDELETEPATCHHEADOPTIONSTRACE
Supported values:
STRINGBYTES
Constructor:
new HttpRequest(String url, HttpMethod method)Exported methods:
| Method | Description |
|---|---|
setBody(body, mediaType) |
Sets request body and media type. |
addHeader(key, value) |
Adds a header. |
send(outputType) |
Sends the request. Accepts OutputType or string. |
import * as http from "http";
const request = new http.HttpRequest("https://example.com", http.HttpMethod.GET);
request.addHeader("Accept", "text/plain");
const response = request.send(http.OutputType.STRING);Factory function:
import { createHttpRequest } from "http";
const request = createHttpRequest("https://example.com", "GET");The module uses OkHttp. Each send creates a new OkHttpClient, builds an OkHttp request, sends it synchronously, and returns either response text or response bytes.
For POST and PUT, an empty request body is created when no body was configured.
The HTTP module performs network requests. Treat it as a privileged capability. ScriptAccess.EXPLICIT controls Java members on exported classes, but it does not block the exported createHttpRequest function or network access itself.