@@ -9,12 +9,15 @@ Table of Contents
99* [ Name] ( #name )
1010* [ Status] ( #status )
1111* [ Synopsis] ( #synopsis )
12+ * [ http subsystem] ( #http-subsystem )
13+ * [ stream subsystem] ( #stream-subsystem )
1214* [ Description] ( #description )
1315* [ Methods] ( #methods )
1416 * [ set_current_peer] ( #set_current_peer )
1517 * [ set_more_tries] ( #set_more_tries )
1618 * [ get_last_failure] ( #get_last_failure )
1719 * [ set_timeouts] ( #set_timeouts )
20+ * [ recreate_request] ( #recreate_request )
1821* [ Community] ( #community )
1922 * [ English Mailing List] ( #english-mailing-list )
2023 * [ Chinese Mailing List] ( #chinese-mailing-list )
7982}
8083```
8184
85+ [ Back to TOC] ( #table-of-contents )
86+
8287stream subsystem
8388----------------
8489
@@ -121,6 +126,8 @@ stream {
121126}
122127```
123128
129+ [ Back to TOC] ( #table-of-contents )
130+
124131Description
125132===========
126133
@@ -237,6 +244,32 @@ This function was first added in the `0.1.7` version of this library.
237244
238245[ Back to TOC] ( #table-of-contents )
239246
247+ recreate_request
248+ ----------------
249+ ** syntax:** ` ok, err = balancer.recreate_request() `
250+
251+ ** context:** * balancer_by_lua* ; *
252+
253+ Recreates the request buffer for sending to the upstream server. This is useful, for example
254+ if you want to change a request header field to the new upstream server on balancer retries.
255+
256+ Normally this does not work because the request buffer is created once during upstream module
257+ initialization and won't be regenerated for subsequent retries. However you can use
258+ ` proxy_set_header My-Header $my_header ` and set the ` ngx.var.my_header ` variable inside the
259+ balancer phase. Calling ` balancer.recreate_request() ` after updating a header field will
260+ cause the request buffer to be re-generated and the ` My-Header ` header will thus contain
261+ the new value.
262+
263+ ** Warning:** because the request buffer has to be recreated and such allocation occurs on the
264+ request memory pool, the old buffer has to be thrown away and will only be freed after the request
265+ finishes. Do not call this function too often or memory leaks may be noticeable. Even so, a call
266+ to this function should be made ** only** if you know the request buffer must be regenerated,
267+ instead of unconditionally in each balancer retries.
268+
269+ This function was first added in the ` 0.1.20 ` version of this library.
270+
271+ [ Back to TOC] ( #table-of-contents )
272+
240273Community
241274=========
242275
0 commit comments