[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-18 (世界標準時間)。"],[[["\u003cp\u003eApigee's default behavior involves buffering HTTP request and response payloads in memory, but streaming can be enabled to send payloads directly to clients or target endpoints.\u003c/p\u003e\n"],["\u003cp\u003eAccessing request or response payloads when streaming is enabled in Apigee will revert the system to the default buffering mode.\u003c/p\u003e\n"],["\u003cp\u003eDisabling streaming by accessing the request/response payload can result in increased latency and higher memory consumption, potentially leading to \u003ccode\u003eOutOfMemory\u003c/code\u003e errors.\u003c/p\u003e\n"],["\u003cp\u003eThe recommended practice is to avoid accessing the request/response payload when streaming is active to maintain the benefits of streaming.\u003c/p\u003e\n"],["\u003cp\u003eStreaming is beneficial for applications that handle large payloads or data delivered in chunks over time.\u003c/p\u003e\n"]]],[],null,["# Antipattern: Accessing the request/response payload when streaming is enabled\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/antipatterns/payload-with-streaming) documentation.*\n\nIn Apigee, the default behavior is that HTTP request and response payloads are stored in an\nin-memory buffer before they are processed by the policies in the API Proxy.\n\nIf streaming is enabled, then request and response payloads are streamed without modification to\nthe client app (for responses) and the target endpoint (for requests). Streaming is useful\nespecially if an application accepts or returns large payloads, or if there's an application that\nreturns data in chunks over time.\n\nAntipattern\n-----------\n\nAccessing the request/response payload with streaming enabled causes Apigee to go back to the\ndefault buffering mode.\n**Figure 1**: Accessing request/response payload with streaming enabled\n\nThe illustration above shows that we are trying to extract variables from the request payload and\nconverting the JSON response payload to XML using JSONToXML policy. This will disable the streaming\nin Apigee.\n\nImpact\n------\n\n- Streaming will be disabled which can lead to increased latencies in processing the data\n- Increase in the heap memory usage or `OutOfMemory` errors can be observed on Message Processors due to use of in-memory buffers especially if we have large request/response payloads\n\nBest practice\n-------------\n\n- Don't access the request/response payload when streaming is enabled.\n\nFurther reading\n---------------\n\n- [Streaming requests and responses](/apigee/docs/api-platform/develop/enabling-streaming)\n- [How does Apigee streaming work?](https://www.googlecloudcommunity.com/gc/Apigee/How-does-APIGEE-Edge-Streaming-work/td-p/38511)\n- [How to handle streaming data together with normal request/response payload in a single API Proxy](https://www.googlecloudcommunity.com/gc/Apigee/How-to-handle-streaming-data-together-with-normal-request/m-p/49986)\n- [Best practices for API proxy design and development](/apigee/docs/api-platform/fundamentals/best-practices-api-proxy-design-and-development)"]]