From 93bddd639dc61fd7c9e18187ab0b9afdc37e52fa Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sat, 19 Oct 2024 12:57:57 +0200 Subject: [PATCH 1/8] Added #parseTokens methods that accept custom delimiters --- .../hc/core5/http/message/MessageSupport.java | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java index b0c6a446b..10bf96d03 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java @@ -168,9 +168,12 @@ public static Header format(final String name, final String... tokens) { } /** - * @since 5.3 + * @since 5.4 */ - public static void parseTokens(final CharSequence src, final ParserCursor cursor, final Consumer consumer) { + public static void parseTokens(final CharSequence src, + final ParserCursor cursor, + final Tokenizer.Delimiter delimiterPredicate, + final Consumer consumer) { Args.notNull(src, "Source"); Args.notNull(cursor, "Cursor"); Args.notNull(consumer, "Consumer"); @@ -179,7 +182,7 @@ public static void parseTokens(final CharSequence src, final ParserCursor cursor if (src.charAt(pos) == ',') { cursor.updatePos(pos + 1); } - final String token = Tokenizer.INSTANCE.parseToken(src, cursor, COMMA); + final String token = Tokenizer.INSTANCE.parseToken(src, cursor, delimiterPredicate); consumer.accept(token); } } @@ -187,31 +190,57 @@ public static void parseTokens(final CharSequence src, final ParserCursor cursor /** * @since 5.3 */ - public static void parseTokens(final Header header, final Consumer consumer) { + public static void parseTokens(final CharSequence src, final ParserCursor cursor, final Consumer consumer) { + parseTokens(src, cursor, COMMA, consumer); + } + + /** + * @since 5.4 + */ + public static void parseTokens(final Header header, + final Tokenizer.Delimiter delimiterPredicate, + final Consumer consumer) { Args.notNull(header, "Header"); if (header instanceof FormattedHeader) { final CharArrayBuffer buf = ((FormattedHeader) header).getBuffer(); final ParserCursor cursor = new ParserCursor(0, buf.length()); cursor.updatePos(((FormattedHeader) header).getValuePos()); - parseTokens(buf, cursor, consumer); + parseTokens(buf, cursor, delimiterPredicate, consumer); } else { final String value = header.getValue(); final ParserCursor cursor = new ParserCursor(0, value.length()); - parseTokens(value, cursor, consumer); + parseTokens(value, cursor, delimiterPredicate, consumer); } } /** * @since 5.3 */ - public static void parseTokens(final MessageHeaders headers, final String headerName, final Consumer consumer) { + public static void parseTokens(final Header header, final Consumer consumer) { + parseTokens(header, COMMA, consumer); + } + + /** + * @since 5.4 + */ + public static void parseTokens(final MessageHeaders headers, + final String headerName, + final Tokenizer.Delimiter delimiterPredicate, + final Consumer consumer) { Args.notNull(headers, "Headers"); final Iterator
it = headers.headerIterator(headerName); while (it.hasNext()) { - parseTokens(it.next(), consumer); + parseTokens(it.next(), delimiterPredicate, consumer); } } + /** + * @since 5.3 + */ + public static void parseTokens(final MessageHeaders headers, final String headerName, final Consumer consumer) { + parseTokens(headers, headerName, COMMA, consumer); + } + public static Set parseTokens(final CharSequence src, final ParserCursor cursor) { Args.notNull(src, "Source"); Args.notNull(cursor, "Cursor"); From 45356e4d135ebef0d726e2400a2de228f1caa236 Mon Sep 17 00:00:00 2001 From: Mario Daniel Ruiz Saavedra Date: Sat, 19 Oct 2024 13:59:18 -0500 Subject: [PATCH 2/8] Add HTTP Method QUERY support --- .../main/java/org/apache/hc/core5/http/Method.java | 7 ++++++- .../http/io/support/ClassicRequestBuilder.java | 12 ++++++++++++ .../core5/http/nio/support/AsyncRequestBuilder.java | 12 ++++++++++++ .../hc/core5/http/protocol/RequestContent.java | 2 +- .../hc/core5/http/support/BasicRequestBuilder.java | 12 ++++++++++++ .../http/io/support/ClassicRequestBuilderTest.java | 13 +++++++++++++ 6 files changed, 56 insertions(+), 2 deletions(-) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java index 731e72d72..b7c077cae 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java @@ -91,7 +91,12 @@ public enum Method { /** * The HTTP {@code PATCH} method is unsafe and non-idempotent. */ - PATCH(false, false); + PATCH(false, false), + + /** + * The HTTP {@code QUERY} method is safe and idempotent. + */ + QUERY(true, true); private final boolean safe; private final boolean idempotent; diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java index 5dd0c1f2f..05af96e84 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java @@ -120,6 +120,18 @@ public static ClassicRequestBuilder head(final String uri) { return new ClassicRequestBuilder(Method.HEAD, uri); } + public static ClassicRequestBuilder query() { + return new ClassicRequestBuilder(Method.QUERY); + } + + public static ClassicRequestBuilder query(final URI uri) { + return new ClassicRequestBuilder(Method.QUERY, uri); + } + + public static ClassicRequestBuilder query(final String uri) { + return new ClassicRequestBuilder(Method.QUERY, uri); + } + public static ClassicRequestBuilder patch() { return new ClassicRequestBuilder(Method.PATCH); } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java index 1c2b99b34..f23ba4567 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java @@ -120,6 +120,18 @@ public static AsyncRequestBuilder head(final String uri) { return new AsyncRequestBuilder(Method.HEAD, uri); } + public static AsyncRequestBuilder query() { + return new AsyncRequestBuilder(Method.QUERY); + } + + public static AsyncRequestBuilder query(final URI uri) { + return new AsyncRequestBuilder(Method.QUERY, uri); + } + + public static AsyncRequestBuilder query(final String uri) { + return new AsyncRequestBuilder(Method.QUERY, uri); + } + public static AsyncRequestBuilder patch() { return new AsyncRequestBuilder(Method.PATCH); } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java index b8c22f84e..24ee1f164 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java @@ -138,7 +138,7 @@ public void process(final HttpRequest request, final EntityDetails entity, final } private boolean isContentEnclosingMethod(final String method) { - return Method.POST.isSame(method) || Method.PUT.isSame(method) || Method.PATCH.isSame(method); + return Method.POST.isSame(method) || Method.PUT.isSame(method) || Method.PATCH.isSame(method) || Method.QUERY.isSame(method); } /** diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java index bdc0cdb85..67f909177 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java @@ -104,6 +104,18 @@ public static BasicRequestBuilder head(final String uri) { return new BasicRequestBuilder(Method.HEAD, uri); } + public static BasicRequestBuilder query() { + return new BasicRequestBuilder(Method.QUERY); + } + + public static BasicRequestBuilder query(final URI uri) { + return new BasicRequestBuilder(Method.QUERY, uri); + } + + public static BasicRequestBuilder query(final String uri) { + return new BasicRequestBuilder(Method.QUERY, uri); + } + public static BasicRequestBuilder patch() { return new BasicRequestBuilder(Method.PATCH); } diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilderTest.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilderTest.java index 729c6b89f..685c42bdf 100644 --- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilderTest.java +++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilderTest.java @@ -109,6 +109,19 @@ void head() throws UnknownHostException, URISyntaxException { assertEquals("/localhost", classicRequestBuilder3.getPath()); } + @Test + void query() throws UnknownHostException, URISyntaxException { + final ClassicRequestBuilder classicRequestBuilder = ClassicRequestBuilder.query(); + assertEquals(Method.QUERY.name(), classicRequestBuilder.getMethod()); + + final ClassicRequestBuilder classicRequestBuilder1 = ClassicRequestBuilder.query(URIBuilder.localhost().build()); + assertEquals(Method.QUERY.name(), classicRequestBuilder1.getMethod()); + + final ClassicRequestBuilder classicRequestBuilder3 = ClassicRequestBuilder.query("/localhost"); + assertEquals(Method.QUERY.name(), classicRequestBuilder3.getMethod()); + assertEquals("/localhost", classicRequestBuilder3.getPath()); + } + @Test void patch() throws UnknownHostException, URISyntaxException { final ClassicRequestBuilder classicRequestBuilder = ClassicRequestBuilder.patch(); From 40d9d2675083ddc304d70b9f154d55504ef56948 Mon Sep 17 00:00:00 2001 From: Mario Daniel Ruiz Saavedra Date: Sat, 19 Oct 2024 14:18:55 -0500 Subject: [PATCH 3/8] Add Javadocs for QUERY @since --- .../src/main/java/org/apache/hc/core5/http/Method.java | 2 ++ .../hc/core5/http/io/support/ClassicRequestBuilder.java | 9 +++++++++ .../hc/core5/http/nio/support/AsyncRequestBuilder.java | 9 +++++++++ .../hc/core5/http/support/BasicRequestBuilder.java | 9 +++++++++ 4 files changed, 29 insertions(+) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java index b7c077cae..6db4df06c 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java @@ -95,6 +95,8 @@ public enum Method { /** * The HTTP {@code QUERY} method is safe and idempotent. + * + * @since 5.4 */ QUERY(true, true); diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java index 05af96e84..79784ef64 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java @@ -120,14 +120,23 @@ public static ClassicRequestBuilder head(final String uri) { return new ClassicRequestBuilder(Method.HEAD, uri); } + /** + * @since 5.4 + */ public static ClassicRequestBuilder query() { return new ClassicRequestBuilder(Method.QUERY); } + /** + * @since 5.4 + */ public static ClassicRequestBuilder query(final URI uri) { return new ClassicRequestBuilder(Method.QUERY, uri); } + /** + * @since 5.4 + */ public static ClassicRequestBuilder query(final String uri) { return new ClassicRequestBuilder(Method.QUERY, uri); } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java index f23ba4567..98617b658 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java @@ -120,14 +120,23 @@ public static AsyncRequestBuilder head(final String uri) { return new AsyncRequestBuilder(Method.HEAD, uri); } + /** + * @since 5.4 + */ public static AsyncRequestBuilder query() { return new AsyncRequestBuilder(Method.QUERY); } + /** + * @since 5.4 + */ public static AsyncRequestBuilder query(final URI uri) { return new AsyncRequestBuilder(Method.QUERY, uri); } + /** + * @since 5.4 + */ public static AsyncRequestBuilder query(final String uri) { return new AsyncRequestBuilder(Method.QUERY, uri); } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java index 67f909177..20381a9b1 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java @@ -104,14 +104,23 @@ public static BasicRequestBuilder head(final String uri) { return new BasicRequestBuilder(Method.HEAD, uri); } + /** + * @since 5.4 + */ public static BasicRequestBuilder query() { return new BasicRequestBuilder(Method.QUERY); } + /** + * @since 5.4 + */ public static BasicRequestBuilder query(final URI uri) { return new BasicRequestBuilder(Method.QUERY, uri); } + /** + * @since 5.4 + */ public static BasicRequestBuilder query(final String uri) { return new BasicRequestBuilder(Method.QUERY, uri); } From 731e683b76022e25bf46ecf1aa78286748211ce3 Mon Sep 17 00:00:00 2001 From: Mario Daniel Ruiz Saavedra Date: Sat, 19 Oct 2024 14:56:21 -0500 Subject: [PATCH 4/8] Add mode documentation on QUERY usage --- .../main/java/org/apache/hc/core5/http/Method.java | 5 +++++ .../http/io/support/ClassicRequestBuilder.java | 14 ++++++++++++++ .../http/nio/support/AsyncRequestBuilder.java | 14 ++++++++++++++ .../hc/core5/http/support/BasicRequestBuilder.java | 14 ++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java index 6db4df06c..a2c973042 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java @@ -95,6 +95,11 @@ public enum Method { /** * The HTTP {@code QUERY} method is safe and idempotent. + *

+ * {@code QUERY} is a method defined to represent a safe, idempotent request that carries a body. + * This allows clients to send a body while enjoying the {@code GET}-like properties (such as easy caching, + * safe CORS handling [if supported] and bookmarking), as well as the {@code POST}-like properties (such as + * being able to send a query in a richer format, and not being limited by URI length and escaping restrictions). * * @since 5.4 */ diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java index 79784ef64..b813104ad 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java @@ -121,6 +121,10 @@ public static ClassicRequestBuilder head(final String uri) { } /** + * Initializes a new {@link ClassicRequestBuilder} instance for the {@code QUERY} method. + * + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static ClassicRequestBuilder query() { @@ -128,6 +132,11 @@ public static ClassicRequestBuilder query() { } /** + * Initializes a new {@link ClassicRequestBuilder} instance for the {@code QUERY} method. + * + * @param uri the request URI. + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static ClassicRequestBuilder query(final URI uri) { @@ -135,6 +144,11 @@ public static ClassicRequestBuilder query(final URI uri) { } /** + * Initializes a new {@link ClassicRequestBuilder} instance for the {@code QUERY} method. + * + * @param uri the request URI. + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static ClassicRequestBuilder query(final String uri) { diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java index 98617b658..c45baff81 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java @@ -121,6 +121,10 @@ public static AsyncRequestBuilder head(final String uri) { } /** + * Initializes a new {@link AsyncRequestBuilder} instance for the {@code QUERY} method. + * + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static AsyncRequestBuilder query() { @@ -128,6 +132,11 @@ public static AsyncRequestBuilder query() { } /** + * Initializes a new {@link AsyncRequestBuilder} instance for the {@code QUERY} method. + * + * @param uri the request URI. + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static AsyncRequestBuilder query(final URI uri) { @@ -135,6 +144,11 @@ public static AsyncRequestBuilder query(final URI uri) { } /** + * Initializes a new {@link AsyncRequestBuilder} instance for the {@code QUERY} method. + * + * @param uri the request URI. + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static AsyncRequestBuilder query(final String uri) { diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java index 20381a9b1..bec92eede 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java @@ -105,6 +105,10 @@ public static BasicRequestBuilder head(final String uri) { } /** + * Initializes a new {@link BasicRequestBuilder} instance for the {@code QUERY} method. + * + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static BasicRequestBuilder query() { @@ -112,6 +116,11 @@ public static BasicRequestBuilder query() { } /** + * Initializes a new {@link BasicRequestBuilder} instance for the {@code QUERY} method. + * + * @param uri the request URI. + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static BasicRequestBuilder query(final URI uri) { @@ -119,6 +128,11 @@ public static BasicRequestBuilder query(final URI uri) { } /** + * Initializes a new {@link BasicRequestBuilder} instance for the {@code QUERY} method. + * + * @param uri the request URI. + * @see Method#QUERY for more information regarding the properties of the {@code QUERY} method. + * * @since 5.4 */ public static BasicRequestBuilder query(final String uri) { From af10afdfd0fc02b5dcc08acefa6fdc34609bd18d Mon Sep 17 00:00:00 2001 From: Mario Daniel Ruiz Saavedra Date: Sat, 19 Oct 2024 15:49:35 -0500 Subject: [PATCH 5/8] Mark QUERY impl as @Experimental --- .../java/org/apache/hc/core5/annotation/Experimental.java | 3 ++- httpcore5/src/main/java/org/apache/hc/core5/http/Method.java | 2 ++ .../hc/core5/http/io/support/ClassicRequestBuilder.java | 4 ++++ .../apache/hc/core5/http/nio/support/AsyncRequestBuilder.java | 4 ++++ .../org/apache/hc/core5/http/support/BasicRequestBuilder.java | 4 ++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java index 6669be793..d1d307ac4 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java @@ -36,7 +36,8 @@ * The field or method to which this annotation is applied is marked as experimental. */ @Documented -@Target({ElementType.METHOD, ElementType.TYPE}) +@Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) @Retention(RetentionPolicy.CLASS) public @interface Experimental { + String reason() default ""; } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java index a2c973042..67f1afc17 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java @@ -29,6 +29,7 @@ import java.util.Locale; +import org.apache.hc.core5.annotation.Experimental; import org.apache.hc.core5.util.Args; /** @@ -103,6 +104,7 @@ public enum Method { * * @since 5.4 */ + @Experimental(reason = "QUERY method is still in DRAFT status") QUERY(true, true); private final boolean safe; diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java index b813104ad..b6619bb54 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/io/support/ClassicRequestBuilder.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.List; +import org.apache.hc.core5.annotation.Experimental; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; @@ -127,6 +128,7 @@ public static ClassicRequestBuilder head(final String uri) { * * @since 5.4 */ + @Experimental public static ClassicRequestBuilder query() { return new ClassicRequestBuilder(Method.QUERY); } @@ -139,6 +141,7 @@ public static ClassicRequestBuilder query() { * * @since 5.4 */ + @Experimental public static ClassicRequestBuilder query(final URI uri) { return new ClassicRequestBuilder(Method.QUERY, uri); } @@ -151,6 +154,7 @@ public static ClassicRequestBuilder query(final URI uri) { * * @since 5.4 */ + @Experimental public static ClassicRequestBuilder query(final String uri) { return new ClassicRequestBuilder(Method.QUERY, uri); } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java index c45baff81..7b16f9774 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncRequestBuilder.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.List; +import org.apache.hc.core5.annotation.Experimental; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; @@ -127,6 +128,7 @@ public static AsyncRequestBuilder head(final String uri) { * * @since 5.4 */ + @Experimental public static AsyncRequestBuilder query() { return new AsyncRequestBuilder(Method.QUERY); } @@ -139,6 +141,7 @@ public static AsyncRequestBuilder query() { * * @since 5.4 */ + @Experimental public static AsyncRequestBuilder query(final URI uri) { return new AsyncRequestBuilder(Method.QUERY, uri); } @@ -151,6 +154,7 @@ public static AsyncRequestBuilder query(final URI uri) { * * @since 5.4 */ + @Experimental public static AsyncRequestBuilder query(final String uri) { return new AsyncRequestBuilder(Method.QUERY, uri); } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java index bec92eede..2d2620510 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/support/BasicRequestBuilder.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.List; +import org.apache.hc.core5.annotation.Experimental; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpRequest; @@ -111,6 +112,7 @@ public static BasicRequestBuilder head(final String uri) { * * @since 5.4 */ + @Experimental public static BasicRequestBuilder query() { return new BasicRequestBuilder(Method.QUERY); } @@ -123,6 +125,7 @@ public static BasicRequestBuilder query() { * * @since 5.4 */ + @Experimental public static BasicRequestBuilder query(final URI uri) { return new BasicRequestBuilder(Method.QUERY, uri); } @@ -135,6 +138,7 @@ public static BasicRequestBuilder query(final URI uri) { * * @since 5.4 */ + @Experimental public static BasicRequestBuilder query(final String uri) { return new BasicRequestBuilder(Method.QUERY, uri); } From 81e6eab6a2920bd4144661bb2d4a7951ac935f46 Mon Sep 17 00:00:00 2001 From: Mario Daniel Ruiz Saavedra Date: Sat, 19 Oct 2024 16:37:55 -0500 Subject: [PATCH 6/8] Rename field --- .../main/java/org/apache/hc/core5/annotation/Experimental.java | 2 +- httpcore5/src/main/java/org/apache/hc/core5/http/Method.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java index d1d307ac4..dbec37487 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java @@ -39,5 +39,5 @@ @Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) @Retention(RetentionPolicy.CLASS) public @interface Experimental { - String reason() default ""; + String value() default ""; // Useful for documenting the reason for the experimental status } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java index 67f1afc17..452c89f73 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java @@ -104,7 +104,7 @@ public enum Method { * * @since 5.4 */ - @Experimental(reason = "QUERY method is still in DRAFT status") + @Experimental("QUERY method is still in DRAFT status") QUERY(true, true); private final boolean safe; From 1b070e83dcbd1934804cd66b8a30216f1c124383 Mon Sep 17 00:00:00 2001 From: Mario Daniel Ruiz Saavedra Date: Sun, 20 Oct 2024 17:28:52 -0500 Subject: [PATCH 7/8] Comment --- .../main/java/org/apache/hc/core5/annotation/Experimental.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java index dbec37487..6a97bf1e4 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java @@ -39,5 +39,5 @@ @Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) @Retention(RetentionPolicy.CLASS) public @interface Experimental { - String value() default ""; // Useful for documenting the reason for the experimental status + String value() default ""; // Useful for documenting the rationale for the experimental status } From 337841106da9169164b0d80c1aff0cd2340702e3 Mon Sep 17 00:00:00 2001 From: Mario Daniel Ruiz Saavedra Date: Thu, 24 Oct 2024 21:03:04 -0500 Subject: [PATCH 8/8] Gave up --- .../main/java/org/apache/hc/core5/annotation/Experimental.java | 1 - httpcore5/src/main/java/org/apache/hc/core5/http/Method.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java index 6a97bf1e4..9781ca840 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/annotation/Experimental.java @@ -39,5 +39,4 @@ @Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) @Retention(RetentionPolicy.CLASS) public @interface Experimental { - String value() default ""; // Useful for documenting the rationale for the experimental status } diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java index 452c89f73..787fb405f 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/Method.java @@ -104,7 +104,8 @@ public enum Method { * * @since 5.4 */ - @Experimental("QUERY method is still in DRAFT status") + @Experimental + //("QUERY method is still in DRAFT status") QUERY(true, true); private final boolean safe;