Skip to content

Commit aa77c68

Browse files
authored
Add default timeout in module http (#3076)
Fixes #3074 * Add timeout * Fix formatting * Fix dashes * Update .po files
1 parent b20764b commit aa77c68

File tree

4 files changed

+164
-163
lines changed

4 files changed

+164
-163
lines changed

doc/reference/reference_lua/http.rst

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Below is a list of all ``http`` functions.
7474
to be free, and close it, in order to avoid exceeding the ``max_connections`` cache size.
7575
In the worst case, libcurl will create a new socket for every request,
7676
even if all requests are going to the same host.
77-
See `this Tarantool issue on github <https://github.com/tarantool/tarantool/issues/3945>`_
77+
See `this Tarantool issue on Github <https://github.com/tarantool/tarantool/issues/3945>`_
7878
for details.
7979

8080
:return: a new HTTP client instance
@@ -104,43 +104,43 @@ Below is a list of all ``http`` functions.
104104
:param table opts: table of connection options, with any of these
105105
components:
106106

107-
* ``ca_file`` - path to an SSL certificate file to verify the peer with
108-
* ``ca_path`` - path to a directory holding one or more certificates to
109-
verify the peer with
110-
* ``headers`` - table of HTTP headers
111-
* ``keepalive_idle`` - delay, in seconds, that the operating system
107+
* ``ca_file`` -- path to an SSL certificate file to verify the peer with.
108+
* ``ca_path`` -- path to a directory holding one or more certificates to
109+
verify the peer with.
110+
* ``headers`` -- table of HTTP headers.
111+
* ``keepalive_idle`` -- delay, in seconds, that the operating system
112112
will wait while the connection is idle before sending keepalive
113113
probes. See also
114114
`CURLOPT_TCP_KEEPIDLE <https://curl.haxx.se/libcurl/c/CURLOPT_TCP_KEEPIDLE.html>`_
115115
and the note below about keepalive_interval.
116-
* ``keepalive_interval`` - the interval, in seconds, that the operating
116+
* ``keepalive_interval`` -- the interval, in seconds, that the operating
117117
system will wait between sending keepalive probes. See also
118118
`CURLOPT_TCP_KEEPINTVL <https://curl.haxx.se/libcurl/c/CURLOPT_TCP_KEEPINTVL.html>`_.
119119
If both ``keepalive_idle`` and ``keepalive_interval`` are set, then
120120
Tarantool will also set HTTP keepalive headers: ``Connection:Keep-Alive``
121121
and ``Keep-Alive:timeout=<keepalive_idle>``.
122-
Otherwise Tarantool will send ``Connection:close``
123-
* ``low_speed_limit`` - set the "low speed limit" -- the average
122+
Otherwise Tarantool will send ``Connection:close``.
123+
* ``low_speed_limit`` -- set the "low speed limit" -- the average
124124
transfer speed in bytes per second that the transfer should be below
125125
during "low speed time" seconds for the library to consider it to be
126126
too slow and abort. See also
127-
`CURLOPT_LOW_SPEED_LIMIT <https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_LIMIT.html>`_
128-
* ``low_speed_time`` - set the "low speed time" -- the time that the
127+
`CURLOPT_LOW_SPEED_LIMIT <https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_LIMIT.html>`_.
128+
* ``low_speed_time`` -- set the "low speed time" -- the time that the
129129
transfer speed should be below the "low speed limit" for the library
130130
to consider it too slow and abort. See also
131-
`CURLOPT_LOW_SPEED_TIME <https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_TIME.html>`_
132-
* ``max_header_name_len`` - the maximal length of a header name. If a header
131+
`CURLOPT_LOW_SPEED_TIME <https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_TIME.html>`_.
132+
* ``max_header_name_len`` -- the maximal length of a header name. If a header
133133
name is bigger than this value, it is truncated to this length.
134134
The default value is '32'.
135-
* ``follow_location`` - when the option is set to ``true`` (default)
135+
* ``follow_location`` -- when the option is set to ``true`` (default)
136136
and the response has a 3xx code, the HTTP client will automatically issue
137137
another request to a location that a server sends in the ``Location``
138138
header. If the new response is 3xx again, the HTTP client will
139139
issue still another request and so on in a loop until a non-3xx response
140140
will be received. This last response will be returned as a result.
141141
Setting this option to ``false`` allows to disable this behavior.
142142
In this case, the HTTP client will return a 3xx response itself.
143-
* ``no_proxy`` - a comma-separated list of hosts that do not require proxies, or '*', or ''.
143+
* ``no_proxy`` -- a comma-separated list of hosts that do not require proxies, or '*', or ''.
144144
Set :samp:`no_proxy = {host} [, {host} ...]` to specify
145145
hosts that can be reached without requiring a proxy, even if ``proxy`` has
146146
been set to a non-blank value and/or if a proxy-related environment variable
@@ -152,44 +152,44 @@ Below is a list of all ``http`` functions.
152152
(HTTP_PROXY) is used.
153153
If ``no_proxy`` is not set, then a proxy-related environment variable
154154
(HTTP_PROXY) may be used. See also
155-
`CURLOPT_NOPROXY <https://curl.haxx.se/libcurl/c/CURLOPT_NOPROXY.html>`_
155+
`CURLOPT_NOPROXY <https://curl.haxx.se/libcurl/c/CURLOPT_NOPROXY.html>`_.
156156
* ``proxy`` - a proxy server host or IP address, or ''.
157157
If ``proxy`` is a host or IP address, then it may begin with a scheme,
158158
for example ``https://`` for an https proxy or ``http://`` for an http proxy.
159-
If ``proxy`` is set to '' an empty string, then proxy use is disabled,
159+
If ``proxy`` is set to '' -- an empty string, then proxy use is disabled,
160160
and no proxy-related environment variable will be used.
161161
If ``proxy`` is not set, then a proxy-related environment variable may be used, such as
162162
HTTP_PROXY or HTTPS_PROXY or FTP_PROXY, or ALL_PROXY if the
163163
protocol can be any protocol. See also
164-
`CURLOPT_PROXY <https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html>`_
164+
`CURLOPT_PROXY <https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html>`_.
165165
* ``proxy_port`` -- a proxy server port.
166166
The default is 443 for an https proxy and 1080 for a non-https proxy.
167167
See also
168-
`CURLOPT_PROXYPORT <https://curl.haxx.se/libcurl/c/CURLOPT_PROXYPORT.html>`_
168+
`CURLOPT_PROXYPORT <https://curl.haxx.se/libcurl/c/CURLOPT_PROXYPORT.html>`_.
169169
* ``proxy_user_pwd`` -- a proxy server user name and/or password.
170170
Format: :samp:`proxy_user_pwd = {user_name}:`
171171
or :samp:`proxy_user_pwd = :{password}`
172172
or :samp:`proxy_user_pwd = {user_name}:{password}`. See also
173-
`CURLOPT_USERPWD <https://curl.haxx.se/libcurl/c/CURLOPT_USERPWD.html>`_
174-
* ``ssl_cert`` - path to a SSL client certificate file. See also
175-
`CURLOPT_SSLCERT <https://curl.haxx.se/libcurl/c/CURLOPT_SSLCERT.html>`_
176-
* ``ssl_key`` - path to a private key file for a TLS and SSL client
173+
`CURLOPT_USERPWD <https://curl.haxx.se/libcurl/c/CURLOPT_USERPWD.html>`_.
174+
* ``ssl_cert`` -- path to a SSL client certificate file. See also
175+
`CURLOPT_SSLCERT <https://curl.haxx.se/libcurl/c/CURLOPT_SSLCERT.html>`_.
176+
* ``ssl_key`` -- path to a private key file for a TLS and SSL client
177177
certificate. See also
178-
`CURLOPT_SSLKEY <https://curl.haxx.se/libcurl/c/CURLOPT_SSLKEY.html>`_
179-
* ``timeout`` - number of seconds to wait for a curl API read request
180-
before timing out
181-
* ``unix_socket`` - a socket name to use instead of an Internet address,
178+
`CURLOPT_SSLKEY <https://curl.haxx.se/libcurl/c/CURLOPT_SSLKEY.html>`_.
179+
* ``timeout`` -- number of seconds to wait for a curl API read request
180+
before timing out. The default timeout is set to infinity (36586400100 seconds).
181+
* ``unix_socket`` -- a socket name to use instead of an Internet address,
182182
for a local connection. The Tarantool server must be built with
183183
``libcurl`` 7.40 or later. See the :ref:`second example <http-example2>`
184184
later in this section.
185-
* ``verbose`` - set on/off verbose mode
186-
* ``verify_host`` - set on/off verification of the certificate's name
185+
* ``verbose`` -- set on/off verbose mode.
186+
* ``verify_host`` -- set on/off verification of the certificate's name
187187
(CN) against host. See also
188-
`CURLOPT_SSL_VERIFYHOST <https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html>`_
189-
* ``verify_peer`` - set on/off verification of the peer's SSL
188+
`CURLOPT_SSL_VERIFYHOST <https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html>`_.
189+
* ``verify_peer`` -- set on/off verification of the peer's SSL
190190
certificate. See also
191-
`CURLOPT_SSL_VERIFYPEER <https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html>`_
192-
* ``accept_encoding`` - enables automatic decompression of HTTP responses
191+
`CURLOPT_SSL_VERIFYPEER <https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html>`_.
192+
* ``accept_encoding`` -- enables automatic decompression of HTTP responses
193193
by setting the contents of the `Accept-Encoding: header` sent in an
194194
HTTP request and enabling decoding of a response when the `Content-Encoding: header`
195195
is received. This option specifies what encoding to use.
@@ -199,15 +199,15 @@ Below is a list of all ``http`` functions.
199199
response using the zlib algorithm, `gzip` which requests the gzip algorithm and `br`
200200
which is brotli. Provide them in the string as a comma-separated list of accepted
201201
encodings, like: ``"br, gzip, deflate"``.
202-
For details of the option, refer to `CURLOPT_ACCEPT_ENCODING <https://curl.haxx.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html>`_
202+
For details of the option, refer to `CURLOPT_ACCEPT_ENCODING <https://curl.haxx.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html>`_.
203203

204204
:return: connection information, with all of these components:
205205

206-
* ``status`` - HTTP response status
207-
* ``reason`` - HTTP response status text
208-
* ``headers`` - a Lua table with normalized HTTP headers
209-
* ``body`` - response body
210-
* ``proto`` - protocol version
206+
* ``status`` -- HTTP response status
207+
* ``reason`` -- HTTP response status text
208+
* ``headers`` -- a Lua table with normalized HTTP headers
209+
* ``body`` -- response body
210+
* ``proto`` -- protocol version
211211

212212
:rtype: table
213213

@@ -256,23 +256,23 @@ Below is a list of all ``http`` functions.
256256
257257
The following "shortcuts" exist for requests:
258258

259-
* ``http_client:get(url, options)`` - shortcut for
259+
* ``http_client:get(url, options)`` -- shortcut for
260260
``http_client:request("GET", url, nil, opts)``
261-
* ``http_client:post (url, body, options)`` - shortcut for
261+
* ``http_client:post (url, body, options)`` -- shortcut for
262262
``http_client:request("POST", url, body, opts)``
263-
* ``http_client:put(url, body, options)`` - shortcut for
263+
* ``http_client:put(url, body, options)`` -- shortcut for
264264
``http_client:request("PUT", url, body, opts)``
265-
* ``http_client:patch(url, body, options)`` - shortcut for
265+
* ``http_client:patch(url, body, options)`` -- shortcut for
266266
``http_client:request("PATCH", url, body, opts)``
267-
* ``http_client:options(url, options)`` - shortcut for
267+
* ``http_client:options(url, options)`` -- shortcut for
268268
``http_client:request("OPTIONS", url, nil, opts)``
269-
* ``http_client:head(url, options)`` - shortcut for
269+
* ``http_client:head(url, options)`` -- shortcut for
270270
``http_client:request("HEAD", url, nil, opts)``
271-
* ``http_client:delete(url, options)`` - shortcut for
271+
* ``http_client:delete(url, options)`` -- shortcut for
272272
``http_client:request("DELETE", url, nil, opts)``
273-
* ``http_client:trace(url, options)`` - shortcut for
273+
* ``http_client:trace(url, options)`` -- shortcut for
274274
``http_client:request("TRACE", url, nil, opts)``
275-
* ``http_client:connect:(url, options)`` - shortcut for
275+
* ``http_client:connect:(url, options)`` -- shortcut for
276276
``http_client:request("CONNECT", url, nil, opts)``
277277

278278
Requests may be influenced by environment variables, for example
@@ -288,15 +288,15 @@ Below is a list of all ``http`` functions.
288288

289289
The ``http_client:stat()`` function returns a table with statistics:
290290

291-
* ``active_requests`` - number of currently executing requests
292-
* ``sockets_added`` - total number of sockets added into an event loop
293-
* ``sockets_deleted`` - total number of sockets sockets from an event loop
294-
* ``total_requests`` - total number of requests
295-
* ``http_200_responses`` - total number of requests which have returned
291+
* ``active_requests`` -- number of currently executing requests
292+
* ``sockets_added`` -- total number of sockets added into an event loop
293+
* ``sockets_deleted`` -- total number of sockets sockets from an event loop
294+
* ``total_requests`` -- total number of requests
295+
* ``http_200_responses`` -- total number of requests which have returned
296296
code HTTP 200
297-
* ``http_other_responses`` - total number of requests which have not
297+
* ``http_other_responses`` -- total number of requests which have not
298298
returned code HTTP 200
299-
* ``failed_requests`` - total number of requests which have failed
299+
* ``failed_requests`` -- total number of requests which have failed
300300
including system errors, curl errors, and HTTP errors
301301

302302
.. _http-example1:

doc/reference/reference_lua/net_box.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ network.
1616

1717
You can call the following methods:
1818

19-
* ``require('net.box')`` to get a ``net.box`` object
20-
(named ``net_box`` for examples in this section),
21-
* ``net_box.connect()`` to connect and get a connection object
22-
(named ``conn`` for examples in this section),
19+
* ``require('net.box')`` -- to get a ``net.box`` object
20+
(named ``net_box`` for examples in this section)
21+
* ``net_box.connect()`` -- to connect and get a connection object
22+
(named ``conn`` for examples in this section)
2323
* other ``net.box()`` routines, passing ``conn:``, to execute requests on
24-
the remote database system,
25-
* ``conn:close`` to disconnect.
24+
the remote database system
25+
* ``conn:close`` -- to disconnect
2626

2727
All ``net.box`` methods are fiber-safe, that is, it is safe to share and use the
2828
same connection object across multiple concurrent fibers. In fact that is perhaps

0 commit comments

Comments
 (0)