Repository navigation
feat(net-http): real Net::HTTP over the socket/TLS transport - #181
Merged
Merged
Conversation
Bind github.com/go-ruby-net-http/net-http (the MRI-byte-exact HTTP/1.1 message codec) onto the just-landed socket transport so Net::HTTP actually performs requests. nethttp.go builds the loadable shell and stubbed every networking method with NotImplementedError; registerNetHTTPTransport now replaces those stubs with real ones that wire the codec to the sockets: NewRequest -> Request.Bytes -> write to a TCPSocket (or a TLS SSLSocket for https) -> read the response off the socket -> ParseResponse -> a Net::HTTPResponse (code / message / body / headers). Surface bound: Net::HTTP.get / get_response / post / post_form / start, instance new + start/finish + the verb helpers (get/head/post/put/delete/ patch/options) + request(req), the Net::HTTP::Get/Post/... request objects (method/path/body/set_form_data), and the response accessors (code/message/ body/http_version/read_body/content_type/each_header) over http AND https. Content-Length and chunked response framing both decode; HEAD is handled. Each request is one connection (Connection: close) so the read drains to EOF. TLS defaults to VERIFY_NONE (the SSLSocket transport's bare-context default); verify_mode = OpenSSL::SSL::VERIFY_PEER turns on Go's chain + hostname verification. Persistent/keep-alive connections, redirect following, proxies, streaming bodies, read timeouts and full certificate- store verification wiring are flagged follow-ups. Proven end-to-end through the rbgo binary against in-process httptest.NewServer (http) and httptest.NewTLSServer (https); 100% coverage on the new binding, hermetic (no external network). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Makes
Net::HTTPactually perform requests, now that the socket/TLS transport (#173) is inmain.What
nethttp.gobuilds the loadable shell (class tree, header surface, HTTPResponse status subclasses) and stubbed every networking method withNotImplementedError. This PR addsinternal/vm/nethttp_bind.go(registerNetHTTPTransport, run right afterregisterNetHTTP) that replaces those stubs with real ones wiring the go-ruby-net-http MRI-byte-exact HTTP/1.1 codec to the socket transport:The wire codec is go-ruby-net-http; the byte I/O is rbgo's own
TCPSocket/OpenSSL::SSL::SSLSockettransport (nethttpDialbuilds atcpSocket, wrapping it in ansslSocketfor https, and reuses the sharedstreamIOwrite/read surface).Surface bound
Net::HTTP.get(→ body String) /get_response/post/post_form/start(host,port){|http| ... }Net::HTTP.new(host,port),start/finish, verb helpersget/head/post/put/delete/patch/options,request(req),use_ssl=/verify_mode=Net::HTTP::Get/Post/...withmethod/path/body/body=/set_form_datacode/message/body/http_version/read_body/content_type/each_header+[](Net::HTTPHeader) + the status subclass identity (Net::HTTPOK,Net::HTTPNotFound, …)Semantics / deviations
Connection: close) so the read drains to EOF.VERIFY_NONE(the SSLSocket transport's bare-context default);verify_mode = OpenSSL::SSL::VERIFY_PEERturns on Go's chain + hostname verification.Deferred follow-ups
Keep-alive / persistent connections, redirect following (Net::HTTP never auto-follows anyway), proxies, streaming bodies, read timeouts, and full certificate-store verification wiring.
Proof
Hermetic, no external network: every assertion drives a Ruby script through the rbgo engine against in-process
httptest.NewServer(http) andhttptest.NewTLSServer(https).TestNetHTTPThroughRbgoBinarybuilds thecmd/rbgobinary and runsNet::HTTP.get(URI(...))against both, asserting the body on stdout. 100% coverage on the new binding code (nethttp_bind.go).🤖 Generated with Claude Code