@@ -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
@@ -238,28 +245,31 @@ This function was first added in the `0.1.7` version of this library.
238245[ Back to TOC] ( #table-of-contents )
239246
240247recreate_request
241- ------------
248+ ----------------
242249** syntax:** ` ok, err = balancer.recreate_request() `
243250
244251** context:** * balancer_by_lua* ; *
245252
246- Regenerates the request buffer for sending to the upstream server. This is useful, for example
253+ Recreates the request buffer for sending to the upstream server. This is useful, for example
247254if you want to change a request header field to the new upstream server on balancer retries.
248255
249256Normally this does not work because the request buffer is created once during upstream module
250257initialization and won't be regenerated for subsequent retries. However you can use
251- ` proxy_set_header My-Header $my_header ` and sets the ` ngx.var.my_header ` variable inside the
252- balancer phase. Calling this function after that will cause the request buffer to be re-generated
253- and the ` My-Header ` header will thus contain the new value.
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.
254262
255263** Warning:** because the request buffer has to be recreated and such allocation occurs on the
256- request memory pool, the old buffer has to be thrown away and only be freed after the request
264+ request memory pool, the old buffer has to be thrown away and will only be freed after the request
257265finishes. Do not call this function too often or memory leaks may be noticeable. Even so, a call
258266to this function should be made ** only** if you know the request buffer must be regenerated,
259267instead of unconditionally in each balancer retries.
260268
261269This function was first added in the ` 0.1.19 ` version of this library.
262270
271+ [ Back to TOC] ( #table-of-contents )
272+
263273Community
264274=========
265275
0 commit comments