@@ -12,26 +12,55 @@ The HTTP client uses the `libcurl <https://curl.haxx.se/libcurl/>`_ library unde
12
12
takes into account the `environment variables <https://curl.haxx.se/libcurl/c/libcurl-env.html >`_ libcurl understands.
13
13
14
14
15
+ .. _http_client_instance :
16
+
17
+ HTTP client instance
18
+ --------------------
19
+
20
+ .. _http_client_instance_default :
21
+
22
+ Default client
23
+ ~~~~~~~~~~~~~~
24
+
25
+ The ``http.client `` submodule provides the default HTTP client instance:
26
+
27
+ .. literalinclude :: /code_snippets/test/http_client/default_client_get_test.lua
28
+ :language: lua
29
+ :lines: 1
30
+
31
+ In this case, you need to make requests using the dot syntax, for example:
32
+
33
+ .. literalinclude :: /code_snippets/test/http_client/default_client_get_test.lua
34
+ :language: lua
35
+ :lines: 2
36
+
37
+
15
38
.. _creating_client :
16
39
17
40
Creating a client
18
- -----------------
41
+ ~~~~~~~~~~~~~~~~~
19
42
20
- To create an HTTP client, call the :ref: `http.client.new() <http-new >` function:
43
+ If you need to configure specific HTTP client options, use the :ref: `http.client.new() <http-new >` function to create the client instance :
21
44
22
45
.. literalinclude :: /code_snippets/test/http_client/get_test.lua
23
46
:language: lua
24
47
:lines: 1
25
48
26
- Optionally, this function can accept specific client configuration options.
49
+ In this case, you need to make requests using the colon syntax, for example:
50
+
51
+ .. literalinclude :: /code_snippets/test/http_client/get_test.lua
52
+ :language: lua
53
+ :lines: 2
54
+
55
+ All the examples in this section use the HTTP client created using ``http.client.new() ``.
27
56
28
57
29
58
.. _making_requests :
30
59
31
60
Making requests
32
61
---------------
33
62
34
- After :ref: `creating the client < creating_client >`, you can make HTTP requests.
63
+ The :ref: `client instance < http_client_instance >` enables you to make HTTP requests.
35
64
36
65
.. _request_http_method :
37
66
@@ -685,7 +714,7 @@ client_object
685
714
686
715
* ``active_requests `` -- the number of currently executing requests
687
716
* ``sockets_added `` -- the total number of sockets added into an event loop
688
- * ``sockets_deleted `` -- the total number of sockets from an event loop
717
+ * ``sockets_deleted `` -- the total number of sockets deleted from an event loop
689
718
* ``total_requests `` -- the total number of requests
690
719
* ``http_200_responses `` -- the total number of requests that returned HTTP ``200 OK `` responses
691
720
* ``http_other_responses `` -- the total number of requests that returned non-``200 OK `` responses
0 commit comments