Skip to content

Commit 1e749c8

Browse files
committed
fixed styling according to @thibaultcha's comments
1 parent 5858696 commit 1e749c8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

lib/ngx/balancer.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ if subsystem == 'http' then
3939
long connect_timeout, long send_timeout,
4040
long read_timeout, char **err);
4141

42-
int
43-
ngx_http_lua_ffi_balancer_recreate_request(ngx_http_request_t *r,
42+
int ngx_http_lua_ffi_balancer_recreate_request(ngx_http_request_t *r,
4443
char **err);
4544
]]
4645

lib/ngx/balancer.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -79,6 +82,8 @@ http {
7982
}
8083
```
8184

85+
[Back to TOC](#table-of-contents)
86+
8287
stream subsystem
8388
----------------
8489

@@ -121,6 +126,8 @@ stream {
121126
}
122127
```
123128

129+
[Back to TOC](#table-of-contents)
130+
124131
Description
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

240247
recreate_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
247254
if you want to change a request header field to the new upstream server on balancer retries.
248255

249256
Normally this does not work because the request buffer is created once during upstream module
250257
initialization 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
257265
finishes. Do not call this function too often or memory leaks may be noticeable. Even so, a call
258266
to this function should be made **only** if you know the request buffer must be regenerated,
259267
instead of unconditionally in each balancer retries.
260268

261269
This function was first added in the `0.1.19` version of this library.
262270

271+
[Back to TOC](#table-of-contents)
272+
263273
Community
264274
=========
265275

0 commit comments

Comments
 (0)