Conversation
ensh63
commented
Feb 13, 2026
- Typed storage in Pool with cleanup support;
- Request context support for HTTP phase modules;
- Simple version of HTTP subrequest support:
- subrequest builder;
- subrequest handler with support of user-supplied function or closure;
- example of use;
- refactoring for Status conversions
There was a problem hiding this comment.
Pull request overview
This PR introduces subrequest support for nginx Rust bindings along with typed storage in Pool and request context management. The changes enable HTTP modules to create and manage subrequests with user-defined handlers, while also adding infrastructure for request-specific context data and improved pool memory management.
Changes:
- Adds HTTP subrequest builder API with support for in-memory, waited, and background subrequests
- Implements RequestContext trait for type-safe, module-scoped request context management with automatic cleanup
- Enhances Pool with typed storage methods (allocate, get_or_add_unique, remove) using cleanup handlers for RAII
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/http/subrequest.rs | New subrequest builder and handler implementation with memory-pool-based allocation |
| src/http/request_context.rs | RequestContext trait for managing typed request-specific data |
| src/http/request.rs | Added get_main/get_main_mut, get_status methods and Result<T,E> IntoHandlerStatus impl |
| src/http/status.rs | Refactored to use TryFrom trait instead of custom from_* methods, simplified error type |
| src/http/mod.rs | Exports new subrequest and request_context modules |
| src/core/pool.rs | Enhanced with typed allocation, unique value storage, and cleanup management |
| src/log.rs | Updated macro to use safe log() method instead of unsafe pointer access |
| examples/subrequest.rs | Example demonstrating subrequest usage with context management |
| examples/Cargo.toml | Added subrequest example configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
acf1162 to
e63cec9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
src/http/status.rs:84
- The refactoring removes the public methods
HTTPStatus::from_u16andHTTPStatus::from_bytesand replaces them withTryFromtrait implementations. This is a breaking API change that could affect existing users of the library. Consider either keeping the old methods as wrappers around the newTryFromimplementations for backward compatibility, or documenting this breaking change in the PR description and release notes.
impl TryFrom<usize> for HTTPStatus {
type Error = InvalidHTTPStatusCode;
#[inline]
fn try_from(value: usize) -> Result<Self, Self::Error> {
if !(100..600).contains(&value) {
return Err(InvalidHTTPStatusCode);
}
Ok(HTTPStatus(value))
}
}
impl TryFrom<isize> for HTTPStatus {
type Error = InvalidHTTPStatusCode;
#[inline]
fn try_from(value: isize) -> Result<Self, Self::Error> {
let value: usize = value.try_into().map_err(|_| InvalidHTTPStatusCode)?;
Self::try_from(value)
}
}
impl TryFrom<&[u8]> for HTTPStatus {
type Error = InvalidHTTPStatusCode;
fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
if value.len() != 3 {
return Err(InvalidHTTPStatusCode);
}
let a = value[0].wrapping_sub(b'0') as u16;
let b = value[1].wrapping_sub(b'0') as u16;
let c = value[2].wrapping_sub(b'0') as u16;
if a == 0 || a > 5 || b > 9 || c > 9 {
return Err(InvalidHTTPStatusCode);
}
let status = (a * 100) + (b * 10) + c;
Ok(HTTPStatus(status.into()))
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e63cec9 to
e2094f7
Compare
cb8d7ac to
961b0c5
Compare
4a44149 to
a626dbf
Compare
856e191 to
98189ce
Compare
98189ce to
cdaff82
Compare
7ad251c to
4764b6b
Compare
f0ae054 to
1c81c70
Compare
1c81c70 to
0cc77a4
Compare