Streaming requests and responses
After reading this topic you will know:
- What request and response streaming on Apigee Edge is
- When to use request and response streaming
- How to enable request and response streaming
If you'd like to jump directly to a code sample, see "Related code samples" for details.
By default, HTTP streaming is disabled and HTTP request and response payloads are written to a buffer in memory before they are processed by the API proxy pipeline. You can change this behavior by enabling streaming. With streaming enabled, request and response payloads are streamed without modification to the client app (for responses) and the target endpoint (for requests).
If your API proxy handles very large requests and/or responses, you may wish to enable streaming. For example, you may wish to enable a streaming response flow if you have a Node.js application deployed on Edge that returns output over time, such as a Comet-style application. Or, you may wish to enable streaming for any application that accepts or returns a very large amount of data.
When streaming is enabled, policies that require access to the request or response payload, such as XSLT transformations and XML to JSON policies cannot be run and are bypassed.
To enable request streaming you need to add the
request.streaming.enabled property to the ProxyEndpoint and TargetEndpoint definitions in the proxy bundle and set it to
true. Similarly, set the
response.streaming.enabled property to enable response streaming.
You can locate these configuration files in the management UI in the Develop view for your proxy. If you are developing locally, these definition files are in
This sample shows how to enable both request and response streaming in the TargetEndpoint definition.
<TargetEndpoint name="default"> <HTTPTargetConnection> <URL>http://weather.yahooapis.com</URL> <Properties> <Property name="response.streaming.enabled">true</Property> <Property name="request.streaming.enabled">true</Property> <Property name="supports.http10">true</Property> <Property name="request.retain.headers">User-Agent,Referer,Accept-Language</Property> <Property name="retain.queryparams">apikey</Property> </Properties> </HTTPTargetConnection> </TargetEndpoint>
This example shows how to enable response and request streaming in the ProxyEndpoint definition:
<ProxyEndpoint name="default"> <HTTPProxyConnection> <URL>http://weather.yahooapis.com</URL> <Properties> <Property name="allow.http10">true</Property> <Property name="response.streaming.enabled">true</Property> <Property name="request.streaming.enabled">true</Property> </Properties> </HTTPProxyConnection> </ProxyEndpoint>
For more information about configuring endpoint definitions, see Endpoint properties reference.
API proxy samples on GitHub are easy to download and use. See Using the sample API proxies for information about downloading and using the samples.
Sample proxies that feature streaming include:
- streaming - Demonstrates an API proxy configured for HTTP streaming.
Help or comments?