← Back to Pull requests

Parse headers in HTTPUtil without commons-httpclient 3 #542

Open
unknown opened this pull request with 344 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 30, 2026 10:43 UTC
Author

What

HTTPUtil.parseHeaders no longer uses commons-httpclient 3's HttpParser. It now delegates to httpcore 4.4's AbstractMessageParser.parseHeaders (httpcore is already on the server classpath), instead of using a custom parser.

Why

This is one step toward dropping commons-httpclient 3.0.1. Following review, it uses an existing, maintained parser rather than hand-written parsing code.

Behaviour changes against httpclient 3

HTTPUtil is user-script API, so these are worth a line in the release notes. Well-formed headers (Name: value lines separated by CRLF or LF, ending at a blank line or EOF) parse the same as before. These corner cases change:

| Input | httpclient 3 | httpcore 4.4 |
|---|---|---|
| Malformed header (no colon, status line, empty name) | org.apache.commons.httpclient.ProtocolException (an IOException), Unable to parse header: <line> | org.apache.http.ProtocolException (not an IOException), Invalid header: <line> |
| Empty header name (:v) | accepted as name "" | rejected |
| Folded line before the first header ( orphan) | silently ignored | rejected |
| Whitespace-only line ( \t ) | ends the header block | treated as a folded continuation, so parsing continues |
| Line that is only a bare CR (\r\r\n) | ends the header block | rejected (Invalid header: [0x10]) |
| Folded continuation of an empty value (X: then b) | " b" | "b" |
| Trailing whitespace on a folded line (a, b , \tc) | "a b c" | "a b c" (only leading whitespace of each fold is dropped) |
| Control characters around a value (\u000ba\u0001) | trimmed (String.trim) | kept; only spaces and tabs are trimmed |
| Non-ASCII on a JVM whose default charset isn't UTF-8 (e.g. Müller under ISO-8859-1) | encoded with the platform charset, so mangled (M?ller) | encoded as UTF-8, so the value round-trips exactly on every platform |

Reviewer notes

  • The first commit adds 19 characterization tests that pass against the old httpclient 3 implementation. The second commit switches to httpcore and updates them to pin its behaviour; each changed assertion is one of the rows above. 21 tests now, and testNonAsciiValue no longer depends on the platform charset.

  • The string is now encoded as UTF-8 rather than with the platform charset. httpcore's decoder rejects malformed input, so keeping the platform charset would have made non-ASCII values throw MalformedInputException on, for example, Java 17 on Windows.

  • No header count or line length limit is applied (-1), matching the old unlimited behaviour.

  • This does not remove the jar yet. That needs the HttpStatus change and the WebDAV rewrite merged too.
  • 🤖 Generated with Claude Code

    Diff: 344 lines (+258 / -86) across 4 files Reviewer: tonygermano Review duration: 46650m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.49) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 344 lines diff across 4 files
    0.49
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.350
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #542"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.4% (MEDIUM) · Higher = larger blast radius
    49.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.3% · Safe to merge
    27.3%