You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2026/04/19 14:03:53 UTC

(httpcomponents-core) 01/01: Updated JSON binding and async examples

This is an automated email from the ASF dual-hosted git repository.

ok2c pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit 18c8eb0bc80db5a0cc41a01ffd0c1514dbe586dd
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sun Apr 19 13:03:51 2026 +0200

    Updated JSON binding and async examples
---
 .../jackson2/http/examples/JsonNodeResponseExample.java      | 10 ++++++++++
 .../jackson2/http/examples/JsonObjectRequestExample.java     | 12 ++++++++++++
 .../jackson2/http/examples/JsonSequenceRequestExample.java   | 11 +++++++++++
 .../jackson2/http/examples/JsonSequenceResponseExample.java  | 11 +++++++++++
 .../hc/core5/jackson2/http/examples/JsonServerExample.java   |  8 +++++++-
 .../http/examples/JsonTokenEventResponseExample.java         | 10 ++++++++++
 .../apache/hc/core5/http/examples/AsyncClientSNIExample.java |  3 +++
 .../hc/core5/http/examples/AsyncFileServerExample.java       |  3 +++
 .../http/examples/AsyncPipelinedRequestExecutionExample.java |  3 +++
 .../hc/core5/http/examples/AsyncRequestExecutionExample.java |  3 +++
 10 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonNodeResponseExample.java b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonNodeResponseExample.java
index 16512773b..a65b446d7 100644
--- a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonNodeResponseExample.java
+++ b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonNodeResponseExample.java
@@ -44,6 +44,16 @@
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.util.Timeout;
 
+/**
+ * This example demonstrates how an HTTP response JSON content can be consumed as
+ * Jackson JsonNode object.
+ * <p>
+ * Please note content of incoming and outgoing HTTP messages gets streamed without making
+ * a copy of the message body content in an intermediate buffer.
+ * <p>
+ * This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use JSON message request producers and response consumers directly.
+ */
 public class JsonNodeResponseExample {
 
     public static void main(final String... args) throws Exception {
diff --git a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonObjectRequestExample.java b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonObjectRequestExample.java
index 05c737008..7096a0730 100644
--- a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonObjectRequestExample.java
+++ b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonObjectRequestExample.java
@@ -47,6 +47,18 @@
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.util.Timeout;
 
+/**
+ * This example demonstrates how a plain Java Object can be serialized as a request
+ * content body in JSON format and an HTTP response JSON content can be consumed as
+ * a plain Java Object compatible with Jackson JSON bindings.
+ *
+ * <p>
+ * Please note content of incoming and outgoing HTTP messages gets streamed without making
+ * a copy of the message body content in an intermediate buffer.
+ * <p>
+ * This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use JSON message request producers and response consumers directly.
+ */
 public class JsonObjectRequestExample {
 
     public static void main(final String... args) throws Exception {
diff --git a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceRequestExample.java b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceRequestExample.java
index ecd788d7a..463953db2 100644
--- a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceRequestExample.java
+++ b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceRequestExample.java
@@ -50,6 +50,17 @@
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.util.Timeout;
 
+/**
+ * This example demonstrates how to stream out a sequence plain Java Objects compatible
+ * with Jackson JSON bindings as a request content body in JSON format.
+ *
+ * <p>
+ * Please note content of incoming and outgoing HTTP messages gets streamed without making
+ * a copy of the message body content in an intermediate buffer.
+ * <p>
+ * This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use JSON message request producers and response consumers directly.
+ */
 public class JsonSequenceRequestExample {
 
     public static void main(final String... args) throws Exception {
diff --git a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceResponseExample.java b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceResponseExample.java
index f1aaf168b..26b794341 100644
--- a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceResponseExample.java
+++ b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceResponseExample.java
@@ -43,6 +43,17 @@
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.util.Timeout;
 
+/**
+ * This example demonstrates how an HTTP response content can be consumed as a sequence
+ * of plain Java Objects compatible with Jackson JSON bindings.
+ *
+ * <p>
+ * Please note content of incoming and outgoing HTTP messages gets streamed without making
+ * a copy of the message body content in an intermediate buffer.
+ * <p>
+ * This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use JSON message request producers and response consumers directly.
+ */
 public class JsonSequenceResponseExample {
 
     public static void main(final String... args) throws Exception {
diff --git a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonServerExample.java b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonServerExample.java
index 65b4fc908..4ebd440a4 100644
--- a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonServerExample.java
+++ b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonServerExample.java
@@ -57,7 +57,13 @@
 import org.apache.hc.core5.util.TimeValue;
 
 /**
- * Example of asynchronous embedded JSON server.
+ * Example of asynchronous embedded HTTP server that exchanges messages in JSON format.
+ * <p>
+ * Please note content of incoming and outgoing HTTP messages gets streamed without making
+ * a copy of the message body content in an intermediate buffer.
+ * <p>
+ * This example uses {@link AsyncJsonServerPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use JSON message consumers and response producers directly.
  */
 public class JsonServerExample {
 
diff --git a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonTokenEventResponseExample.java b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonTokenEventResponseExample.java
index 085e428c7..fb3dd8e67 100644
--- a/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonTokenEventResponseExample.java
+++ b/httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonTokenEventResponseExample.java
@@ -43,6 +43,16 @@
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.util.Timeout;
 
+/**
+ * This example demonstrates how an HTTP response JSON content can be consumed as
+ * a stream of events.
+ * <p>
+ * Please note content of incoming and outgoing HTTP messages gets streamed without making
+ * a copy of the message body content in an intermediate buffer.
+ * <p>
+ * This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use JSON message request and response consumers directly.
+ */
 public class JsonTokenEventResponseExample {
 
     public static void main(final String... args) throws Exception {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncClientSNIExample.java b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncClientSNIExample.java
index 7fd39e550..89cb0912d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncClientSNIExample.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncClientSNIExample.java
@@ -53,6 +53,9 @@
 
 /**
  * Example of SNI (Server Name Identification) usage with async I/O.
+ * <p>
+ * This example uses {@link AsyncClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use message request producers and response consumers directly.
  */
 public class AsyncClientSNIExample {
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncFileServerExample.java b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncFileServerExample.java
index 4c60b977c..2c085627a 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncFileServerExample.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncFileServerExample.java
@@ -63,6 +63,9 @@
 
 /**
  * Example of asynchronous embedded HTTP/1.1 file server.
+ * <p>
+ * This example uses {@link AsyncServerPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use message request consumers and response producers directly.
  */
 public class AsyncFileServerExample {
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java
index e67467c28..f86f0342c 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java
@@ -50,6 +50,9 @@
 
 /**
  * Example of asynchronous HTTP/1.1 request execution.
+ * <p>
+ * This example uses {@link AsyncClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use message request producers and response consumers directly.
  */
 public class AsyncPipelinedRequestExecutionExample {
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncRequestExecutionExample.java b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncRequestExecutionExample.java
index 3f210aa40..a67f15789 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncRequestExecutionExample.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncRequestExecutionExample.java
@@ -48,6 +48,9 @@
 
 /**
  * Example of asynchronous HTTP/1.1 request execution.
+ * <p>
+ * This example uses {@link AsyncClientPipeline} to simplify HTTP message execution pipeline
+ * assembly. One can also use message request producers and response consumers directly.
  */
 public class AsyncRequestExecutionExample {