http.request
Send an HTTP request and give the status, the headers and the body
CLI- Package
- @procedures/http · README
- Path
["http","request"]- CLI
mark http request --url <string>- As data
{"$proc":["http","request"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/http/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["http","request"], { url: "<url>" });
console.log(JSON.stringify(result));From the command line
$ mark http request --url <string>
As data, in a program
{ "$proc": ["http", "request"], "input": { "url": "<url>" } }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | yes | The URL: http: or https: | |
method | "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | no | The method (default: GET) | |
headers | object | no | The headers of the request | |
query | object | no | More parameters for the query of the URL. A list gives the parameter more than one time | |
body | string | no | A body of text | |
json | any | no | A body of JSON: the procedure sets content-type: application/json | |
bodyBase64 | string | no | A body of bytes in base64 | |
responseType | "text" | "json" | "bytes" | no | The form of the body of the response: text (default), json, or bytes in base64 | |
timeoutMs | integer | no | The time of the whole call, in milliseconds (default: 30000) | |
maxResponseBytes | integer | no | The largest body of the response, in bytes. The default and the maximum is the limit of the module (10 MiB) | |
redirect | "follow" | "manual" | "error" | no | What to do with a redirect: follow it (default), give it (manual), or fail (error) | |
maxRedirects | integer | no | The most redirects that the call follows (default: 5) |
Output
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
status | integer | yes | The status of the response | |
statusText | string | yes | The reason phrase of the status | |
ok | boolean | yes | True for a status in 200 to 299 | |
url | string | yes | The URL of the response: the last URL after the redirects | |
redirected | boolean | yes | True when the call followed a redirect | |
headers | object | yes | The headers of the response, with names in lowercase | |
body | any | yes | The body: text, parsed JSON (null when empty), or bytes in base64 | |
bytes | integer | yes | The size of the body in bytes, after the content encoding |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri",
"description": "The URL: http: or https:"
},
"method": {
"description": "The method (default: GET)",
"type": "string",
"enum": [
"GET",
"HEAD",
"POST",
"PUT",
"PATCH",
"DELETE",
"OPTIONS"
]
},
"headers": {
"description": "The headers of the request",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "string"
}
},
"query": {
"description": "More parameters for the query of the URL. A list gives the parameter more than one time",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"anyOf": [
{
"type": [
"string",
"number",
"boolean"
]
},
{
"type": "array",
"items": {
"type": [
"string",
"number",
"boolean"
]
}
}
]
}
},
"body": {
"description": "A body of text",
"type": "string"
},
"json": {
"description": "A body of JSON: the procedure sets content-type: application/json"
},
"bodyBase64": {
"description": "A body of bytes in base64",
"type": "string",
"format": "base64",
"contentEncoding": "base64",
"pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$"
},
"responseType": {
"description": "The form of the body of the response: text (default), json, or bytes in base64",
"type": "string",
"enum": [
"text",
"json",
"bytes"
]
},
"timeoutMs": {
"description": "The time of the whole call, in milliseconds (default: 30000)",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 86400000
},
"maxResponseBytes": {
"description": "The largest body of the response, in bytes. The default and the maximum is the limit of the module (10 MiB)",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"redirect": {
"description": "What to do with a redirect: follow it (default), give it (manual), or fail (error)",
"type": "string",
"enum": [
"follow",
"manual",
"error"
]
},
"maxRedirects": {
"description": "The most redirects that the call follows (default: 5)",
"type": "integer",
"minimum": 0,
"maximum": 20
}
},
"required": [
"url"
]
},
"output": {
"type": "object",
"properties": {
"status": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991,
"description": "The status of the response"
},
"statusText": {
"type": "string",
"description": "The reason phrase of the status"
},
"ok": {
"type": "boolean",
"description": "True for a status in 200 to 299"
},
"url": {
"type": "string",
"description": "The URL of the response: the last URL after the redirects"
},
"redirected": {
"type": "boolean",
"description": "True when the call followed a redirect"
},
"headers": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"description": "The headers of the response, with names in lowercase"
},
"body": {
"description": "The body: text, parsed JSON (null when empty), or bytes in base64"
},
"bytes": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991,
"description": "The size of the body in bytes, after the content encoding"
}
},
"required": [
"status",
"statusText",
"ok",
"url",
"redirected",
"headers",
"body",
"bytes"
],
"additionalProperties": false
}
}