Repository navigation
Accept HTTP::Request and HTTP::Response in validate - #5
Merged
Merged
Conversation
validate now takes an HTTP::Request and/or HTTP::Response as the named request and response. A response given without a request brings its own ($response->request), which is used even when only the response is checked; an explicit request always wins. The private OpenAPI::Humbug::Adapter::HTTPMessage converts them to the existing hashes; it is loaded only when one of those objects is passed, and HTTP::Message stays optional (suggested). The objects are only read, never changed. Closes #3. Co-Authored-By: Claude Opus 5.5 <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.
Closes #3.
validatenow acceptsHTTP::RequestandHTTP::Responseas the namedrequestandresponse:The conversion lives in
OpenAPI::Humbug::Adapter::HTTPMessage, documented as internal. It turns the objects into the existing request/response hashes, which then go through the usual argument checks and encoding. The sidecar, wire protocol and transport are unchanged, and there's no adapter registry.Behaviour (documented under HTTP::MESSAGE in the POD)
Which request:
response => $http_responseand norequest, the response's own request ($http_response->request) is used, even withvalidate => { request => 0, response => 1 }, because the sidecar needs it to find the operation.request(object or hash) always wins, even when it differs.No positional form:
validate($http_response)is an argument error that says to pass it asresponse =>.Optional: HTTP::Message is never loaded by this module, and the adapter is loaded only when one of these objects is passed. In
META.jsonit is a runtime suggests and a test recommends. A test hides HTTP::Message and checks that hashref callers work and nothing related gets loaded.Read-only: objects are never changed.
HTTP::Message'sheaders,headerandcontentwould generate the body (and rewriteContent-Type) for a message built withparts/add_part. Such a message is rejected before any of those are called, and the test checks it is left unchanged. The tests also compareData::Dumpersnapshots of the request and response before and after.URL: the request's URI without fragment or credentials (cleared explicitly). It must be absolute with a scheme and host.
HTTP::Requesthas no base URL andHostgives no scheme, so a relative URI is an argument error, not a guess.Headers: every line is sent, and repeated lines (
Set-Cookie) stay separate and in order. WhatHTTP::Headersloses is documented, not reconstructed:Folded values are unfolded to a space (RFC 9112 §5.2); otherwise the sidecar would reject the raw line break. Values that are objects (e.g.
URI) are stringified.Body: raw
content, neverdecoded_content. Content from a code reference, or held as parts, is an argument error.Absent vs empty: the same RFC 9112 §6.3 rules as the Mojo adapter.
Content-LengthorTransfer-Encoding.Tests
t/openapi_humbug__http_message.t: in-memory against the fake transport, checking the exact wire form. Covers request-only, request plus response, response with its associated request, response without one, positional response rejected, explicit request winning, response-only checks keeping the request, repeatedSet-Cookie, binary/non-ASCII/empty header values, folded values, raw/binary/empty/absent bodies, absolute/relative URIs and missing scheme/host, messages that can't be converted, and objects left unchanged.t/openapi_humbug__no_http_message.t: hashref callers with HTTP::Message hidden.t/integration.t: request, response with its request, and response-only checks against the real humbug.CI
maint/cip-before-installnow also installs HTTP::Message, so these tests run in the linux workflow.🤖 Generated with Claude Code