Skip to content

feat(http): expose upstream_states and request timing/byte accessors#291

Open
u5surf wants to merge 1 commit into
nginx:mainfrom
u5surf:feat/request-upstream-states-accessor
Open

feat(http): expose upstream_states and request timing/byte accessors#291
u5surf wants to merge 1 commit into
nginx:mainfrom
u5surf:feat/request-upstream-states-accessor

Conversation

@u5surf
Copy link
Copy Markdown

@u5surf u5surf commented May 25, 2026

Proposed changes

Add safe accessors for request struct fields that previously required raw-pointer deref:

  • Request::upstream_states() -> &[UpstreamState] walks each upstream attempt (one per peer for proxy_next_upstream retries) via a #[repr(transparent)] wrapper exposing peer, status, response_time, connect_time, header_time, queue_time, bytes_sent, bytes_received, response_length.
  • Request::start_sec(), start_msec(), request_length(), bytes_sent() for the request-level timing/byte fields.

Request::upstream() (the raw-pointer accessor) is left untouched to preserve compatibility.

Unit tests follow the MaybeUninit::zeroed pattern from #272.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have written my commit messages in the Conventional Commits format.
  • I have read the CONTRIBUTING doc
  • I have added tests (when possible) that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Add safe accessors for request struct fields that previously
required raw-pointer deref:

  - `Request::upstream_states() -> &[UpstreamState]` walks each
    upstream attempt (one per peer for `proxy_next_upstream`
    retries) via a `#[repr(transparent)]` wrapper exposing
    `peer`, `status`, `response_time`, `connect_time`,
    `header_time`, `queue_time`, `bytes_sent`, `bytes_received`,
    `response_length`.
  - `Request::start_sec()`, `start_msec()`, `request_length()`,
    `bytes_sent()` for the request-level timing/byte fields.

`Request::upstream()` (the raw-pointer accessor) is left untouched
to preserve compatibility.

Unit tests follow the `MaybeUninit::zeroed` pattern from nginx#272.

Signed-off-by: Y.Horie <u5.horie@gmail.com>
@u5surf u5surf force-pushed the feat/request-upstream-states-accessor branch from 2d4aceb to 0cec0b9 Compare May 25, 2026 10:25
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