You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cleaned up contribution by @arsenalzp.
Added more test cases for blocking and non-blocking.
Added documentation.
Signed-off-by: Simone Bordet <[email protected]>
Copy file name to clipboardExpand all lines: documentation/jetty/modules/code/examples/src/main/java/org/eclipse/jetty/docs/programming/client/http/HTTPClientDocs.java
+37Lines changed: 37 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,13 @@
20
20
importjava.net.SocketAddress;
21
21
importjava.net.URI;
22
22
importjava.nio.ByteBuffer;
23
+
importjava.nio.channels.SocketChannel;
23
24
importjava.nio.file.Path;
24
25
importjava.nio.file.Paths;
25
26
importjava.util.List;
26
27
importjava.util.concurrent.CompletableFuture;
28
+
importjava.util.concurrent.ConcurrentHashMap;
29
+
importjava.util.concurrent.ConcurrentMap;
27
30
importjava.util.concurrent.TimeUnit;
28
31
importjavax.net.ssl.SSLEngine;
29
32
importjavax.net.ssl.SSLException;
@@ -1233,4 +1236,38 @@ public void connectionInformation() throws Exception
In order to send a request, it is necessary to obtain a connection, as explained in the xref:request-processing[request processing section].
547
547
@@ -562,6 +562,25 @@ This means that the connection is not available in the _request queued_ event, b
562
562
For more information about request events, see xref:non-blocking[this section].
563
563
====
564
564
565
+
[[connection-events]]
566
+
=== Connection Events
567
+
568
+
In order to send HTTP requests, a connection is necessary, as explained in the xref:request-processing[request processing section].
569
+
570
+
HTTP/1.1 and HTTP/2 use `SocketChannel.connect(SocketAddress)` to establish a connection with the server, either via the TCP transport or via the Unix-Domain transport.
571
+
572
+
You can listen to these `connect` events using a `ClientConnector.ConnectListener`, for example to record connection establishment times:
This could be particularly useful when you notice that your client application seem "slow" to send requests.
580
+
The `connect begin` and `connect success` events, along with the `request queued` and `request begin` event (detailed xref:non-blocking[here]), allow you to understand whether it is the server being slow at accepting connections, or it is the client being slow at processing queued requests.
581
+
582
+
Once the low-level connection has been established, you can be notified of connection events using a `Connection.Listener`, or more concretely `ConnectionStatistics`, as described in xref:arch/io.adoc#connection-listener[this section].
0 commit comments