---
title: HttpClient
description: Ports, terminal outcomes, settings and qualification evidence for
  the HttpClient connector.
url: https://docs.rastok.com/reference/connectors/http-client
source_revision: v0.2.0-alpha
---

# HttpClient

`std/http-client@1`. One HTTP request per Call. Usable response bodies include non-success statuses. Decoded 500–599 responses use `ServerError`; other final statuses use `Completed`. A body decoding fault takes precedence over status classification.

## Declaration

For an `http://` URL, the default is HTTP/1.1. To contact a server that
requires cleartext HTTP/2, set `versions = ["http/2"]`. An HTTPS URL
continues to use the declared order.

This declaration comes from `crates/rastok/src/lab.rs`. Place the Connector in a Graph
and wire its ports; the excerpt alone is not an App.

```rkg
connector network : HttpClient {
  url = "https://example.test/v1"
  timeout = duration("5s")
  codec = json
  idempotent = true; behavior = deterministic
}
```

The [contract index](/reference/contracts.md) explains shared settings, build features
and the distinction between a Contract, a Lab model and an installed Driver.

Calls on one instance are serialized; [queue time counts toward `timeout`](/reference/execution.md#instances-own-state-not-threads).

| Mode | Driver direction | Exchange | Lab model | Installed in this binary |
|---|---|---|---|---|
| No selector | outbound | call | `lab-call` | Not compiled |

## Ports and completion

| Mode | Port | Direction | Type rule |
|---|---|---|---|
| all | `in` | input | `codec = bytes` → `array<byte>`; `codec = json` → `variant`; `codec = string` → `string` |
| all | `out` | output | `codec = bytes` → `array<byte>`; `codec = json` → `variant`; `codec = string` → `string`; explicit JSON response type admitted |
| all | `exit` | output | HttpClientExit, below |

| Mode | Output cardinality |
|---|---|
| all | Status 204 or 205: `Completed` with no `out`. Other `Completed` and `ServerError`: one `out`. Every Call ends with one `exit`. |

## Exit union

| Case | Payload | Call visibility |
|---|---|---|
| `BodyTooLarge` | `{ limit: ulong }` | outcome_unknown |
| `Completed` | `{ status: int }` | after_effect |
| `ConnectFailed` | Empty | before_effect |
| `DecodeFailed` | `{ message: string }` | outcome_unknown |
| `DnsFailed` | Empty | before_effect |
| `OutcomeUnknown` | Empty | outcome_unknown |
| `ProtocolFailed` | Empty | outcome_unknown |
| `ServerError` | `{ status: int }` | after_effect |
| `TimeoutExpired` | Empty | outcome_unknown |
| `TlsFailed` | Empty | before_effect |

## Settings

With `codec = json`, `rastok check` refuses a producer whose resolved type
contains a [value without a JSON form](/reference/types.md#json-request-values), using
`E-TYPE-INVALID`. A `variant` producer is checked at execution instead: an
unencodable request ends the Call with `DecodeFailed` before it is sent.
Its message names `in` and the required codec representation. The JSON
input is a `variant`; its object keys are not declared field names.

For a typed JSON **response**, a `timestamp` field reads a UTC string such
as `"2026-01-05T08:30:00.25Z"`. A `timestamp?` also admits `null`.
An invalid or offset date ends the Call with `DecodeFailed` and no `out`
delivery. In a `data is DecodeFailed` branch, `data.message` identifies
the response field and what it expected. If the body is not JSON it names
`out` instead. The message contains neither the rejected value nor a
peer-supplied map key. To inspect the original value, receive it as a string or leave
the response untyped.

A request URL can include a numeric identifier: `url = "https://example.test/jobs/" + string(data.id)`.
The number becomes a string explicitly; the JSON request codec does not change.

| Mode | Setting | Domain | Presence / default | Latest phase |
|---|---|---|---|---|
| all | `auth_bearer` | `string` | optional | invocation |
| all | `behavior` | `deterministic \| probabilistic` | required | plan |
| all | `codec` | `bytes \| json \| string` | required | plan |
| all | `json_profile` | `projected` | optional | plan |
| all | `idempotent` | `bool` | `false` | plan |
| all | `headers` | `HTTP headers` | optional | invocation |
| all | `custom_headers` | `map<string,array<string>>` | optional | invocation |
| all | `idempotency_key` | `string` | optional | invocation |
| all | `max_body` | `ByteSize` | `"8MiB"` | plan |
| all | `method` | `string` | `"GET"` | invocation |
| all | `timeout` | `duration` | required | instance |
| all | `tls_ca` | `array<byte>` | optional | instance |
| all | `tls_certificate` | `array<byte>` | optional | instance |
| all | `tls_private_key` | `array<byte>` | optional | instance |
| all | `url` | `string` | required | invocation |
| all | `versions` | `array<http/1.1 \| http/2 \| http/3>` | `["http/3", "http/2", "http/1.1"]` | plan |
| all | `zero_rtt` | `disabled` | `disabled` | plan |

`codec = json` permits an explicit `output out: Response`. `json_profile = projected` additionally skips extra members and fills absent nullable fields, while rejecting malformed required values. `auth_bearer = secret(...)` and `url = env(...)` use the declared boot-reference seam even though the table lists each setting's latest general phase. Those references are resolved from deployment configuration at startup, not from an input envelope. There is no automatic redirect or Retry: the graph declares its Retry policy.

## Qualification inventory

fixture `crates/rastok/tests/conformance_http_client.rs`. Cases without a portable forced fixture: `DnsFailed`, `OutcomeUnknown`. Related tests: `crates/rastok/src/connector/drivers/network/http_client.rs`.
