From the architecture review, "Inside rproxy", under "The body wrappers hold the whole request": #283 (comment). Approved for building: #283 (comment). The code was read at 809d266 on next. Line numbers are that commit's.
What is there
requestBody and responseBody in internal/rproxy/bodies.go each hold rq *request. Their Read is called on other goroutines than the handler's: the transport's, and the one that copies the app's answer.
requestBody uses the pointer for one call: b.rq.refuse(http.StatusRequestEntityTooLarge) (line 71).
responseBody uses it for three things: b.rq.responseReceived() (line 103), b.rq.refuse(http.StatusBadGateway) (lines 105 and 111), and b.rq.in.Context() (line 108).
Why it matters
With the whole request in reach, the type does not say what another goroutine may touch. refuse is safe there because refused is atomic. The next field someone reads through b.rq may not be.
What changes
Each wrapper holds only what it calls:
requestBody gets a refuse func(status int);
responseBody gets that, a function to call once the app's whole answer has arrived, and the request's context.
Neither holds a *request.
What stays
request goes on reading the fields of its own requestBody (held, waiting, received, bytes, mu, stopped). That direction is not the finding.
upgradedConn and responseWriter are untouched.
Done when
neither wrapper has a field of type *request;
behaviour is unchanged: every existing test passes with no assertion changed;
make check passes;
the PR body lists every new field name.
Model: fable-5-2
From the architecture review, "Inside `rproxy`", under "The body wrappers hold the whole request": https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173849. Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`. Line numbers are that commit's.
### What is there
- `requestBody` and `responseBody` in `internal/rproxy/bodies.go` each hold `rq *request`. Their `Read` is called on other goroutines than the handler's: the transport's, and the one that copies the app's answer.
- `requestBody` uses the pointer for one call: `b.rq.refuse(http.StatusRequestEntityTooLarge)` (line 71).
- `responseBody` uses it for three things: `b.rq.responseReceived()` (line 103), `b.rq.refuse(http.StatusBadGateway)` (lines 105 and 111), and `b.rq.in.Context()` (line 108).
### Why it matters
With the whole request in reach, the type does not say what another goroutine may touch. `refuse` is safe there because `refused` is atomic. The next field someone reads through `b.rq` may not be.
### What changes
Each wrapper holds only what it calls:
- `requestBody` gets a `refuse func(status int)`;
- `responseBody` gets that, a function to call once the app's whole answer has arrived, and the request's context.
Neither holds a `*request`.
### What stays
- `request` goes on reading the fields of its own `requestBody` (`held`, `waiting`, `received`, `bytes`, `mu`, `stopped`). That direction is not the finding.
- `upgradedConn` and `responseWriter` are untouched.
### Done when
- neither wrapper has a field of type `*request`;
- behaviour is unchanged: every existing test passes with no assertion changed;
- `make check` passes;
- the PR body lists every new field name.
Model: fable-5-2
clawbot
self-assigned this 2026-11-19 17:12:20 +01:00
PR: #457, branch issue-431-body-wrapper-fields. Both body wrappers now hold callbacks for what they call instead of the *request, plus the request's context for responseBody.
Model: opus-5-5
PR: https://git.eeqj.de/sneak/smallwebwaf/pulls/457, branch `issue-431-body-wrapper-fields`. Both body wrappers now hold callbacks for what they call instead of the `*request`, plus the request's context for `responseBody`.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
From the architecture review, "Inside
rproxy", under "The body wrappers hold the whole request": #283 (comment). Approved for building: #283 (comment). The code was read at809d266onnext. Line numbers are that commit's.What is there
requestBodyandresponseBodyininternal/rproxy/bodies.goeach holdrq *request. TheirReadis called on other goroutines than the handler's: the transport's, and the one that copies the app's answer.requestBodyuses the pointer for one call:b.rq.refuse(http.StatusRequestEntityTooLarge)(line 71).responseBodyuses it for three things:b.rq.responseReceived()(line 103),b.rq.refuse(http.StatusBadGateway)(lines 105 and 111), andb.rq.in.Context()(line 108).Why it matters
With the whole request in reach, the type does not say what another goroutine may touch.
refuseis safe there becauserefusedis atomic. The next field someone reads throughb.rqmay not be.What changes
Each wrapper holds only what it calls:
requestBodygets arefuse func(status int);responseBodygets that, a function to call once the app's whole answer has arrived, and the request's context.Neither holds a
*request.What stays
requestgoes on reading the fields of its ownrequestBody(held,waiting,received,bytes,mu,stopped). That direction is not the finding.upgradedConnandresponseWriterare untouched.Done when
*request;make checkpasses;Model: fable-5-2
PR: #457, branch
issue-431-body-wrapper-fields. Both body wrappers now hold callbacks for what they call instead of the*request, plus the request's context forresponseBody.Model: opus-5-5