From c208d3f1c435367292f674aee77a647abb2a2089 Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Fri, 10 Jul 2026 10:08:20 -0500 Subject: [PATCH] =?UTF-8?q?feat(client):=20HttpTransport=20=E2=80=94=20rea?= =?UTF-8?q?l=20HTTPRequest=20transport=20(untested=20shim)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- client/scripts/net/http_transport.gd | 35 ++++++++++++++++++++++++ client/scripts/net/http_transport.gd.uid | 1 + 2 files changed, 36 insertions(+) create mode 100644 client/scripts/net/http_transport.gd create mode 100644 client/scripts/net/http_transport.gd.uid diff --git a/client/scripts/net/http_transport.gd b/client/scripts/net/http_transport.gd new file mode 100644 index 0000000..2b53f65 --- /dev/null +++ b/client/scripts/net/http_transport.gd @@ -0,0 +1,35 @@ +extends "res://scripts/net/dm_transport.gd" +## The real transport: wraps an HTTPRequest Node the owner added to the tree. +## This is the one untested shim in the slice — it needs a live Node and a +## server, so it is verified by reading and by the harness live smoke, the same +## way the server's HTTP boundary is covered only by its gated --run-live test. +## A non-2xx status is NOT an error here; it is a normal DmResponse the service +## interprets. Only a transport-level failure (no response) yields failed(). + +const ProxyConfig = preload("res://scripts/net/proxy_config.gd") +const DmResponse = preload("res://scripts/net/dm_response.gd") + +var _http: HTTPRequest + + +func _init(http: HTTPRequest) -> void: + _http = http + + +func post_json(path: String, body: Dictionary) -> DmResponse: + var url := ProxyConfig.base_url() + path + var headers := ["Content-Type: application/json"] + var payload := JSON.stringify(body) + var err := _http.request(url, headers, HTTPClient.METHOD_POST, payload) + if err != OK: + return DmResponse.failed("request() failed to start: error %d" % err) + # request_completed(result, response_code, headers, body) — awaiting a + # multi-arg signal returns the args as an Array. + var signal_args: Array = await _http.request_completed + var result: int = signal_args[0] + var response_code: int = signal_args[1] + var raw: PackedByteArray = signal_args[3] + if result != HTTPRequest.RESULT_SUCCESS: + return DmResponse.failed("transport result %d" % result) + var parsed = JSON.parse_string(raw.get_string_from_utf8()) # null if not JSON + return DmResponse.ok(response_code, parsed) diff --git a/client/scripts/net/http_transport.gd.uid b/client/scripts/net/http_transport.gd.uid new file mode 100644 index 0000000..267fe08 --- /dev/null +++ b/client/scripts/net/http_transport.gd.uid @@ -0,0 +1 @@ +uid://cuvhnqsgr3liq