ngx_chain_t connects buffers into a linked chain for NGINX HTTP output processing. A response containing one buffer uses that buffer with next set to a null pointer. section 4.6
Build a response chain incrementally:
- Configure ngx_buf_t with the response buffer's start and end pointers. section 4.6
- Initialize ngx_chain_t with the buffer pointer and a null next pointer. section 4.6
- Pass the chain to ngx_http_output_filter to send the response data. section 4.6
Single-buffer response
A response copies its bytes into NGINX-managed memory, assigns the allocation to buf.pos and computes buf.last, then creates ngx_chain_t { buf, next: null_mut() }. section 4.6
buf.pos = response_buffer as *mut u8;
buf.last = response_buffer.offset(
response_bytes.len() as isize) as *mut u8;
let mut out_chain = ngx_chain_t {
buf,
next: std::ptr::null_mut(),
};
Inspect the Rust construction of ngx_chain_t after buffer pointers are assigned. section 4.6
