Repository navigation
Adds the HTTP transport seam under statifier/basichttp - #26
Merged
Merged
Conversation
The Basic HTTP processor needs a way to make a request that a host can replace and that the tests can drive without a network. A transport is any callable that takes a frozen Request (http_method, url, headers, body) and answers a frozen Response (status, headers, body), whatever its status, or raises TransportError when no response came back. NetHTTPTransport is the default, on the standard library's Net::HTTP, so the gem keeps its one runtime dependency. It makes one attempt, bounds each step by five seconds unless told otherwise, and takes a host's own connection through connect:. All of it loads only on require "statifier/basichttp"; a test asks a fresh process that require "statifier" alone loads no HTTP library. The transport's tests run Net::HTTP's own request writer and response parser against in-memory bytes, so no socket is opened. Refs: srb-x2q
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the HTTP transport, the seam the Basic HTTP processor will make its requests through. Refs: srb-x2q.
What it adds
require "statifier/basichttp"(lib/statifier/basichttp.rb) loadsStatifier::BasicHTTP.require "statifier"alone loads none of it and no HTTP library. The Basic HTTP processor on an opt-in require with an injected transport, Net::HTTP the default, was ruled by the operator, 2026-10-23.call. It takes oneStatifier::BasicHTTP::Requestand answers aStatifier::BasicHTTP::Responsewhatever its status, or raisesStatifier::BasicHTTP::TransportErrorwhen no response came back.Request:http_method,url,headers(name and value pairs, in order),body. It is a frozenDatavalue built from copies. It refuses a method or header name that is not an HTTP token, and a header value holding CR, LF or NUL.Response:status(an Integer from 100 to 599),headers,body. Also frozen and built from copies. A status outside 2xx is a response, not an error.TransportError: the one error class. The error that caused it is itscause.Statifier::BasicHTTP::NetHTTPTransport, on the standard library's Net::HTTP (thenet-httpdefault gem). The gemspec is unchanged, sopredicatoris still the one runtime dependency. Each call makes one attempt. Opening the connection, writing and reading are each bounded bytimeout:seconds, five when absent, which is the reference's bound inStatifier.Send.BasicHTTP.Transport.Httpcat v2.16.0. A URL that is not an absolute http or https URL with a host raises before any connection is opened.NetHTTPTransport.connection(uri, timeout:)builds the default connection (not started), andconnect:takes a host's own.changelog.d/srb-x2q.md.How the tests avoid the network
The default transport's tests (
test/basichttp/net_http_transport_test.rb) passconnect:a test double,BasicHTTPHelper::Connectionintest/basichttp/basichttp_helper.rb. The double'srequesttakes the request Net::HTTP built and writes it into a string through Net::HTTP's own serializer (Net::HTTPGenericRequest#execover aNet::BufferedIOon aStringIO). It then answers a response that Net::HTTP's own parser (Net::HTTPResponse.read_newandreading_body) reads from canned bytes. No socket is opened and no server is started.test/basichttp/load_test.rbasks a fresh Ruby process two things: thatrequire "statifier"loads neithernet/httpnorNet::HTTPnorStatifier::BasicHTTP, and thatrequire "statifier/basichttp"loads all three.Provenance
http_method, notmethod. ADatamember namedmethodoverridesObject#method, and the lint configuration refuses that (Lint/DataDefineOverride). This was decided by the conductor under a standing consent, 2026-10-23.connect:is an option a host passes to set a proxy or certificate settings, and it is also how the tests reach below Net::HTTP without a socket.NetHTTPTransport#connect(uri)answers the connection a call would open, either the host's or the default. Both are public and documented. Neither is a test-only path inlib/. This was decided by the conductor under a standing consent, 2026-10-23.Gate
mise exec -- bundle exec rakegreen on the committed tree: rubocop, corpus:check, registry, then 650 runs with 0 failures, line coverage 99.82% and branch coverage 96.56%. Every new test that asserts library behaviour carries a one-line sabotage note, and each of those mutations was applied, turned its test red on an assertion, and was then restored.