Skip to content

dump the Content-Length the pipeline client now sends - #8367

Merged
Mzack9999 merged 2 commits into
devfrom
fix/pipeline-dump-content-length
Dec 2, 2026
Merged

Mzack9999 merged 2 commits into
devfrom
fix/pipeline-dump-content-length

Conversation

@dogancanbakir

@dogancanbakir dogancanbakir commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #8366

Mirrors projectdiscovery/rawhttp#568 in newPipelinedRequest: a body the caller did not frame gets Content-Length, from req.ContentLength when set. Dev CI is red on TestPipelinedRequestDumpMatchesWire until this lands.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected Content-Length handling for pipelined HTTP requests with a body. The header is now included only when neither Content-Length nor Transfer-Encoding is already present, and a supplied positive content length is preserved. This prevents conflicting length information and keeps request dumps consistent with the headers sent by the client.

@dogancanbakir dogancanbakir added this to the nuclei v4 milestone Dec 1, 2026
@dogancanbakir dogancanbakir self-assigned this Dec 1, 2026
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Pipelined request dumps now include Content-Length for non-empty bodies when neither Content-Length nor Transfer-Encoding is set. The expected request in the test includes this header.

Changes

Pipelined request dump

Layer / File(s) Summary
Content-Length in pipelined request dumps
pkg/protocols/http/utils.go, pkg/protocols/http/utils_test.go
For a non-empty body without Content-Length or Transfer-Encoding, the dump uses positive req.ContentLength when set, or the body length otherwise. The comment and test reflect the header in the dumped request.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: dwisiswant0, mzack9999

Merge Risk: Minimal · up to 7069a

This change makes the pipelined request dump include Content-Length for bodies the caller has not framed, matching what the HTTP client sends on the wire. No actionable merge risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the pipelined request dump now includes the Content-Length that the pipeline client sends. The raw summary says newPipelinedRequest now adds Content-Length for a nonem…
Linked Issues check Passed [#8366] The issue requires the pipelined request dump to include the Content-Length that rawhttp v0.3.2+ sends for a body. At head, newPipelinedRequest in pkg/protocols/http/utils.go appends a `Cont…
Out of Scope Changes check Passed The changed code stays within the scope of #8366. The utils.go change adds the Content-Length framing logic and the strconv import it needs. The doc comments on dumpPipelinedRequest and `newPipeli…
Full details: Title check

Explanation

The title names the main change: the pipelined request dump now includes the Content-Length that the pipeline client sends. The raw summary says newPipelinedRequest now adds Content-Length for a nonempty body when neither Content-Length nor Transfer-Encoding is present, using req.ContentLength when set. The objectives match this, as they aim to make the dump match the rawhttp wire output. The title is specific and short, and it is free of file lists or vague wording.

Full details: Linked Issues check

Explanation

[#8366] The issue requires the pipelined request dump to include the Content-Length that rawhttp v0.3.2+ sends for a body. At head, newPipelinedRequest in pkg/protocols/http/utils.go appends a Content-Length header when the body is non-empty and neither Content-Length nor Transfer-Encoding is set by the caller (checked with hasHeaderFold). The value is req.ContentLength when positive, otherwise len(body). Headers are then sorted for a stable order. TestDumpPipelinedRequestWritesWhatTheClientSends expects Content-Length: 32 for a 32-byte body, and also checks that no Content-Length appears for a body-less request. The code and the test agree. Limits: the whole-PR diff could not be read (changed blobs unavailable), so the base version of the test was not compared. I did not run the test suite, and I did not check rawhttp v0.3.3 source, so the CI result is not confirmed by execution. The Transfer-Encoding skip is inferred from the code, not from the rawhttp source.

Full details: Out of Scope Changes check

Explanation

The changed code stays within the scope of #8366. The utils.go change adds the Content-Length framing logic and the strconv import it needs. The doc comments on dumpPipelinedRequest and newPipelinedRequest describe the same behavior. The utils_test.go change covers the same dump path. The test assertion message mentions 'the client's own Content-Length', which is slightly inaccurate because nuclei adds the header, not the caller. This wording does not affect behavior or the verdict. The whole-PR diff could not be read, so this check relies on the file contents at head and the summaries.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the headers in a row,
A body’s length is set before they go.
When no length or transfer mark is there,
The dump records the bytes with care.
Then off the pipelined requests flow.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 17bfc51b-f880-471e-8afc-acc2b440e0ea
Commits

Reviewing files that changed from the base of the PR and between 5e89712 and 7069ae4.

Files selected for processing: 2

  • pkg/protocols/http/utils.go
  • pkg/protocols/http/utils_test.go
Files skipped from review as they are similar to previous changes: 1

  • pkg/protocols/http/utils_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@Mzack9999
Mzack9999 merged commit 55615da into dev Dec 2, 2026
20 checks passed
@Mzack9999
Mzack9999 deleted the fix/pipeline-dump-content-length branch December 2, 2026 12:14
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.

pipelined request dump misses the Content-Length rawhttp v0.3.2 sends

2 participants