Skip to content

[http] --json collapses duplicate response headers and types body.bytes as a string #277

Closed

Description

@Antruly

A proxy-style consumer cannot reconstruct the response faithfully:

  • headers is a JSON object, so repeated headers collapse into one
    comma-joined value. A response with several Set-Cookie lines cannot be
    represented (observed against www.baidu.com).
  • body.bytes is a string ("29506") while status and timing.* are
    numbers.
  • There is no raw header list; header name casing is lost.

Suggestion:

  • add headers_raw: [{name, value}] preserving order, duplicates, and spelling,
    keeping headers as the convenience view;
  • make body.bytes a number (or add bytes_number);
  • expose body.base64 for non-text bodies and mark text decoding as lossy.

Activity

  1. Antruly commented on Oct 19, 2026

    @Antruly
    OwnerAuthor

    Review — checked at bc17f63 (uvp-agents 0.4.0)

    • Duplicate headers: confirmed. A local server sending two Set-Cookie and two X-Dupe lines yields:

      "headers": {
        "set-cookie": "a=1; Path=/, b=2; Path=/",
        "x-dupe": "one, two",
        ...
      }

      No raw list, and header name casing is lower-cased — both as described.

    • body.bytes is a number here, not a string. Same run: "bytes": 11. Against https://www.baidu.com: "bytes": 29506, type number. Forced HTTP/2: "bytes": 129, type number. The schema declares bytes: z.number().int() (src/contracts/webToolContracts.ts:104) and the projection is bytes: exchange.body.byteLength (src/application/WebService.ts:164).

      I could not reproduce the quoted "29506". If it is still visible, please add the exact command and version — it may come from a different path (the HTTP/3 native probe is the one that reads its byte count from a subprocess report) or an older build. My judgment: drop or re-scope the bytes half until it reproduces, and keep the header half, which does.

    The headers_raw suggestion is the right shape: headers stays the convenience view, and the ordered duplicate-preserving list is what a proxy consumer can actually reconstruct from.

  2. Antruly commented on Oct 19, 2026

    @Antruly
    OwnerAuthor

    🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

    Claiming this task as Antruly-dev-1. I will follow
    docs/ai-engineer-operations.md and docs/agent-workflow.md.
    Planned scope: add an ordered, duplicate- and case-preserving headers_raw list to uvp_http_request's output (name/value pairs as received), keeping headers as the convenience view, and leave the body.bytes half alone since your review could not reproduce it. The wire data has to come from the HTTP stack's own response object, so the first step is checking what libuvcpp exposes before deciding whether the full raw list is available or a narrower, truthful claim is the only one that can be made.

  3. Antruly commented on Oct 19, 2026

    @Antruly
    OwnerAuthor

    🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1

    Status: in review — draft PR #285 (fix/277-headers-raw, head f32bc23).

    uvp_http_request now reports headers_raw for HTTP/1.1: wire order, original spelling, duplicates kept; headers stays the convenience view. HTTP/2 and HTTP/3 expose no raw list, so the field is absent there rather than an empty list — asserted against a real h2c session. The fixture has a /duplicate-headers route written as raw header pairs; two mutation probes are killed. The body.bytes half is not changed: your review could not reproduce it, and the schema and projection already type it as a number. Full suite 1674 passed / 14 named skips; the only failures are the two host-environmental real-toolchain files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions