For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Body buffering
Buffer request and response bodies before forwarding them.
Use the traffic.buffer policy to buffer request or response bodies in the gateway proxy before the bodies are forwarded. By default, agentgateway streams bodies. When you configure traffic.buffer, the proxy accumulates the configured body direction in memory until the body is complete, and then forwards it.
frontend.http.maxBufferSize limit used by policies that need buffering.Buffer settings
You can configure request buffering, response buffering, or both.
| Field | Description | Default |
|---|---|---|
traffic.buffer.request.maxBytes | Maximum number of request body bytes to buffer. | Uses the global proxy buffer setting, which defaults to 2Mi. |
traffic.buffer.response.maxBytes | Maximum number of response body bytes to buffer. | Uses the global proxy buffer setting, which defaults to 2Mi. |
The maxBytes value accepts byte-size strings such as 32Ki, 2Mi, or 10M. Large buffered bodies can increase proxy memory usage, so set strict limits for routes that receive untrusted or large payloads. When a body exceeds the applicable buffer limit, agentgateway rejects the body if possible. If response headers were already sent before the limit is exceeded, the proxy closes the connection.
Before you begin
- Set up an agentgateway proxy.
- Install the httpbin sample app.
Buffer request and response bodies
Use a AgentgatewayPolicy to configure body buffering for a Gateway, HTTPRoute, or route rule.
Create a policy that buffers request bodies up to
64Kiand response bodies up to256Ki.kubectl apply -f- <<EOF apiVersion: agentgateway.dev/v1alpha1 kind: AgentgatewayPolicy metadata: name: body-buffer namespace: agentgateway-system spec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: agentgateway-proxy traffic: buffer: request: maxBytes: 64Ki response: maxBytes: 256Ki EOFReview the policy.
kubectl get AgentgatewayPolicy body-buffer -n agentgateway-system -o yaml
Cleanup
You can remove the resources that you created in this guide.kubectl delete AgentgatewayPolicy body-buffer -n agentgateway-system