Skip to content

Commit a427405

Browse files
committed
mark some function params as optional
1 parent 0cc4aad commit a427405

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

meta/3rd/OpenResty/library/ngx.lua

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ function ngx.decode_base64(str) end
12371237
--- An optional boolean-typed `no_padding` argument can be specified to control whether the base64 padding should be appended to the resulting digest (default to `false`, i.e., with padding enabled).
12381238
---
12391239
---@param str string
1240-
---@param no_padding boolean
1240+
---@param no_padding? boolean
12411241
---@return string
12421242
function ngx.encode_base64(str, no_padding) end
12431243

@@ -1537,7 +1537,7 @@ function DICT:flush_all() end
15371537
---
15381538
--- Unlike the `flush_all` method, this method actually frees up the memory used by the expired items.
15391539
---
1540-
---@param max_count number
1540+
---@param max_count? number
15411541
---@return number flushed
15421542
function DICT:flush_expired(max_count) end
15431543

@@ -1548,7 +1548,7 @@ function DICT:flush_expired(max_count) end
15481548
---
15491549
--- **CAUTION** Avoid calling this method on dictionaries with a very large number of keys as it may lock the dictionary for significant amount of time and block NGINX worker processes trying to access the dictionary.
15501550
---
1551-
---@param max_count number
1551+
---@param max_count? number
15521552
---@return string[] keys
15531553
function DICT:get_keys(max_count) end
15541554

@@ -2042,7 +2042,7 @@ function ngx.req.set_body_data(data) end
20422042
---
20432043
--- Removing the `max_args` cap is strongly discouraged.
20442044
---
2045-
---@param max_args number
2045+
---@param max_args? number
20462046
---@return table args
20472047
---@return string|'"truncated"' error
20482048
function ngx.req.get_post_args(max_args) end
@@ -2272,7 +2272,7 @@ function ngx.req.get_method() end
22722272
---
22732273
--- You can use the "raw request socket" returned by `ngx.req.socket(true)` to implement fancy protocols like `WebSocket`, or just emit your own raw HTTP response header or body data. You can refer to the `lua-resty-websocket library` for a real world example.
22742274
---
2275-
---@param raw boolean
2275+
---@param raw? boolean
22762276
---@return tcpsock? socket
22772277
---@return string? error
22782278
function ngx.req.socket(raw) end
@@ -2313,7 +2313,7 @@ function ngx.req.finish_body() end
23132313
---
23142314
--- This method does not work in HTTP/2 requests yet.
23152315
---
2316-
---@param no_request_line boolean
2316+
---@param no_request_line? boolean
23172317
---@return string
23182318
function ngx.req.raw_header(no_request_line) end
23192319

@@ -2348,7 +2348,7 @@ function ngx.req.start_time() end
23482348
---
23492349
--- This function can be used with `ngx.req.append_body`, `ngx.req.finish_body`, and `ngx.req.socket` to implement efficient input filters in pure Lua (in the context of `rewrite_by_lua*` or `access_by_lua*`), which can be used with other NGINX content handler or upstream modules like `ngx_http_proxy_module` and `ngx_http_fastcgi_module`.
23502350
---
2351-
---@param buffer_size number
2351+
---@param buffer_size? number
23522352
function ngx.req.init_body(buffer_size) end
23532353

23542354
--- Set the current request's request body using the in-file data specified by the `file_name` argument.
@@ -2362,7 +2362,7 @@ function ngx.req.init_body(buffer_size) end
23622362
--- Whether the previous request body has been read into memory or buffered into a disk file, it will be freed or the disk file will be cleaned up immediately, respectively.
23632363
---
23642364
---@param file_name string
2365-
---@param auto_clean boolean
2365+
---@param auto_clean? boolean
23662366
function ngx.req.set_body_file(file_name, auto_clean) end
23672367

23682368
--- Clears the current request's request header named `header_name`. None of the current request's existing subrequests will be affected but subsequently initiated subrequests will inherit the change by default.
@@ -2628,7 +2628,7 @@ function ngx.encode_args(args) end
26282628
--- Removing the `max_args` cap is strongly discouraged.
26292629
---
26302630
---@param str string
2631-
---@param max_args number
2631+
---@param max_args? number
26322632
---@return table args
26332633
---@return string|'"truncated"' error
26342634
function ngx.decode_args(str, max_args) end
@@ -2684,8 +2684,8 @@ local udpsock = {}
26842684
---
26852685
--- Calling this method on an already connected socket object will cause the original connection to be closed first.
26862686
---
2687-
---@param host string
2688-
---@param port number
2687+
---@param host string
2688+
---@param port? number
26892689
---@return boolean ok
26902690
---@return string? error
26912691
function udpsock:setpeername(host, port) end
@@ -2845,8 +2845,8 @@ local tcpsock = {}
28452845
--- Calling this method on an already connected socket object will cause the original connection to be closed first.
28462846
---
28472847
---@param host string
2848-
---@param port number
2849-
---@param opts tcpsock.connect.opts
2848+
---@param port? number
2849+
---@param opts? tcpsock.connect.opts
28502850
---@return boolean ok
28512851
---@return string? error
28522852
function tcpsock:connect(host, port, opts) end
@@ -2900,11 +2900,12 @@ function tcpsock:connect(host, port, opts) end
29002900
--- For connections that have already done SSL/TLS handshake, this method returns
29012901
--- immediately.
29022902
---
2903-
---@param reused_session? userdata|boolean
2904-
---@param server_name string
2905-
---@param ssl_verify boolean
2906-
---@param send_status_req boolean
2903+
---@param reused_session? userdata|boolean
2904+
---@param server_name? string
2905+
---@param ssl_verify? boolean
2906+
---@param send_status_req? boolean
29072907
---@return userdata|boolean session_or_ok
2908+
---@return string? error
29082909
function tcpsock:sslhandshake(reused_session, server_name, ssl_verify, send_status_req) end
29092910

29102911

@@ -2967,7 +2968,7 @@ function tcpsock:send(data) end
29672968
---
29682969
---@overload fun(self:tcpsock, size:number):string,string,string
29692970
---
2970-
---@param pattern '"*a"'|'"*l"'
2971+
---@param pattern? '"*a"'|'"*l"'
29712972
---@return string? data
29722973
---@return string? error
29732974
---@return string? partial
@@ -3090,7 +3091,7 @@ function tcpsock:receiveany(max) end
30903091
---@overload fun(self:tcpsock, size:number, options:table):ngx.socket.tcpsock.iterator
30913092
---
30923093
---@param pattern string
3093-
---@param options table
3094+
---@param options? table
30943095
---@return ngx.socket.tcpsock.iterator
30953096
function tcpsock:receiveuntil(pattern, options) end
30963097

@@ -3249,8 +3250,8 @@ function tcpsock:setoption(option, value) end
32493250
---
32503251
--- This method also makes the current cosocket object enter the "closed" state, so there is no need to manually call the `close` method on it afterwards.
32513252
---
3252-
---@param timeout number
3253-
---@param size number
3253+
---@param timeout? number
3254+
---@param size? number
32543255
---@return boolean ok
32553256
---@return string? error
32563257
function tcpsock:setkeepalive(timeout, size) end
@@ -3278,7 +3279,7 @@ function tcpsock:getreusedtimes() end
32783279
--- There is no way to use the `settimeout` method to specify connecting timeout for this method and the `lua_socket_connect_timeout` directive must be set at configure time instead.
32793280
---
32803281
---@param host string
3281-
---@param port number
3282+
---@param port? number
32823283
---@return tcpsock? socket
32833284
---@return string? error
32843285
function ngx.socket.connect(host,port) end
@@ -3478,9 +3479,10 @@ function ngx.exit(status) end
34783479
--- It is recommended that a coding style that combines this method call with the `return` statement, i.e., `return ngx.redirect(...)` be adopted when this method call is used in contexts other than `header_filter_by_lua*` to reinforce the fact that the request processing is being terminated.
34793480
---
34803481
---@param uri string
3481-
---@param status number
3482+
---@param status? 301|302|303|307|308
34823483
function ngx.redirect(uri, status) end
34833484

3485+
34843486
--- Registers a user Lua function as the callback which gets called automatically when the client closes the (downstream) connection prematurely.
34853487
---
34863488
--- Returns `1` if the callback is registered successfully or returns `nil` and a string describing the error otherwise.
@@ -3570,7 +3572,7 @@ function ngx.on_abort(callback) end
35703572
--- It is recommended that a coding style that combines this method call with the `return` statement, i.e., `return ngx.exec(...)` be adopted when this method call is used in contexts other than `header_filter_by_lua*` to reinforce the fact that the request processing is being terminated.
35713573
---
35723574
---@param uri string
3573-
---@param args string|table<string,any>
3575+
---@param args? string|table<string,any>
35743576
function ngx.exec(uri, args) end
35753577

35763578
ngx.location = {}
@@ -3832,7 +3834,7 @@ ngx.location = {}
38323834
--- Please also refer to restrictions on capturing locations configured by subrequest directives of other modules.
38333835
---
38343836
---@param uri ngx.location.capture.uri
3835-
---@param options ngx.location.capture.options
3837+
---@param options? ngx.location.capture.options
38363838
---@return ngx.location.capture.response
38373839
function ngx.location.capture(uri, options) end
38383840

@@ -4185,7 +4187,7 @@ function ngx.send_headers() end
41854187
---
41864188
--- Returns `1` on success, or returns `nil` and a string describing the error otherwise.
41874189
---
4188-
---@param wait boolean
4190+
---@param wait? boolean
41894191
---@return boolean ok
41904192
---@return string? error
41914193
function ngx.flush(wait) end

0 commit comments

Comments
 (0)