Skip to content

feat(http-request): add readIncomingResponse and type aliases#143

Merged
John-David Dalton (jdalton) merged 1 commit into
mainfrom
feat/read-incoming-message
Apr 5, 2026
Merged

feat(http-request): add readIncomingResponse and type aliases#143
John-David Dalton (jdalton) merged 1 commit into
mainfrom
feat/read-incoming-message

Conversation

@jdalton

Copy link
Copy Markdown
Collaborator

Summary

  • Add readIncomingResponse(msg) — reads and buffers a client-side IncomingResponse into an HttpResponse. Useful for converting raw responses from code that bypasses httpRequest() (e.g. multipart form-data uploads) into the standard HttpResponse interface.
  • Add IncomingResponse type alias — IncomingMessage received as a response to a client request
  • Add IncomingRequest type alias — IncomingMessage received as a request in a server handler
  • Update internal httpRequestAttempt callbacks to use IncomingResponse
  • All three exported from @socketsecurity/lib/http-request

Why the type aliases

Node's IncomingMessage is used for both client responses and server requests. The aliases disambiguate which context you're in, making call sites self-documenting.

Test plan

  • 12 new tests for readIncomingResponse: JSON, text, 404, 500, binary, arrayBuffer, large bodies, undefined statusCode, header preservation, invalid JSON from .json(), parity with httpRequest output
  • 2 new tests for type aliases
  • All 136 http-request tests pass
  • All 167 isolated tests pass
  • Build, lint, typecheck pass

Add readIncomingResponse() to read and buffer a client-side
IncomingResponse into an HttpResponse. Useful for converting raw
responses from code that bypasses httpRequest() (e.g. multipart
form-data uploads) into the standard HttpResponse interface.

Add IncomingResponse and IncomingRequest type aliases to disambiguate
Node's IncomingMessage which is used for both client responses and
server requests.
@jdalton John-David Dalton (jdalton) merged commit 4ef6437 into main Apr 5, 2026
11 of 12 checks passed
@jdalton John-David Dalton (jdalton) deleted the feat/read-incoming-message branch April 5, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant