/
nv-lang
/
nova-http
Обзор
Документация
Войти
/
nv-lang
/
nova-http
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
src/client/client_test.nv
34 строки
2 KB
Evgeniy Golovin
fix(приёмка №79): send/into_client вместо into_send/into_build — send=эффектное действие (Http), не конверсия (ось §1а не покрывает); build→into_client (имя цели финализации); nova:allow на @send до эффект-исключения в линте
25 июл 2026, 00:54
25 июл 2026, 00:54
aa5b349
Код
Авторство
О чём код?
// SPDX-License-Identifier: MIT OR Apache-2.0 // http-props (2026-07-07): `HttpClientBuilder` copying config setters // (@default_header/@redirect/@user_agent/@no_decompress/@max_decompressed) → // mutating fleeting properties (D117 AMEND-2). A shallow copy of a `value`-typed // builder shares its heap-backed `default_headers` list with the pre-call // instance — no real independence, just an extra allocation. Canon: `mut @x(v) // -> @`, auto self-return (D409); chains need a `mut`-bound receiver. module http.client import http.{Http} // [M-http-props-mut-chain-stmt-value-copy-loss] цепочка до фикса — chaining // `b.default_header(..).user_agent(..)` in ONE statement on a `value`-type // receiver (`HttpClientBuilder`) compiles/runs but silently drops the mutation // (verified with a minimal repro + std/http/server's `ServerResponse.@header` // case). Reported to the owner 2026-07-07. Workaround: one setter call per // statement on the SAME `mut` binding. test "HttpClientBuilder: mutating chain applies BOTH settings on one instance" { ro m = mock_http() .on("GET", "/echo-header", MockResponse.echo_request_header("x-trace")) .on("GET", "/echo-ua", MockResponse.echo_request_header("user-agent")) with Http = effect Http { send(host, port, secure, request) -> Result[str, HttpError] { m.reply(request) } } { mut b = HttpClient.builder() b.default_header("X-Trace", "abc") b.user_agent("nova-test/1.0") ro client = b.into_client()!! consume r1 = client.get("http://x.example/echo-header").send()!! assert(r1.into_text()!! == "abc") consume r2 = client.get("http://x.example/echo-ua").send()!! assert(r2.into_text()!! == "nova-test/1.0") } }