You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "arturobernalg (via GitHub)" <gi...@apache.org> on 2026/07/04 17:35:07 UTC

[PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

arturobernalg opened a new pull request, #844:
URL: https://github.com/apache/httpcomponents-client/pull/844

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #844:
URL: https://github.com/apache/httpcomponents-client/pull/844#discussion_r3543922679


##########
httpclient5-jakarta-rest-client/src/main/java/org/apache/hc/client5/http/rest/RestInvocationHandler.java:
##########
@@ -244,6 +251,21 @@ private CompletableFuture<?> dispatchAsync(final Class<?> rawType,
                         return result.getBody();
                     });
         }
+        if (isNameValuePairCollection(method, async)) {
+            return submit(requestProducer, new RestResponseConsumer<>(objectMapper, StringAsyncEntityConsumer::new))
+                    .thenApply(result -> {
+                        throwIfError(result);
+                        final Header header = result.getHead().getFirstHeader(HttpHeaders.CONTENT_TYPE);
+                        final ContentType contentType = header != null ? ContentType.parse(header.getValue()) : null;

Review Comment:
   @ok2c done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg merged PR #844:
URL: https://github.com/apache/httpcomponents-client/pull/844


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #844:
URL: https://github.com/apache/httpcomponents-client/pull/844#issuecomment-4885417057

   @arturobernalg Great! But we also need a content consumer, don't we?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #844:
URL: https://github.com/apache/httpcomponents-client/pull/844#discussion_r3536825014


##########
httpclient5-jakarta-rest-client/src/main/java/org/apache/hc/client5/http/rest/RestInvocationHandler.java:
##########
@@ -244,6 +251,21 @@ private CompletableFuture<?> dispatchAsync(final Class<?> rawType,
                         return result.getBody();
                     });
         }
+        if (isNameValuePairCollection(method, async)) {
+            return submit(requestProducer, new RestResponseConsumer<>(objectMapper, StringAsyncEntityConsumer::new))
+                    .thenApply(result -> {
+                        throwIfError(result);
+                        final Header header = result.getHead().getFirstHeader(HttpHeaders.CONTENT_TYPE);
+                        final ContentType contentType = header != null ? ContentType.parse(header.getValue()) : null;

Review Comment:
   @arturobernalg One small thing. Let's make ContentType parsing more efficient:
   ```
   final ContentType contentType = header != null ? MessageSupport.parserHeaderValue(header, ContentType::parse) : null;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #844:
URL: https://github.com/apache/httpcomponents-client/pull/844#discussion_r3524854070


##########
httpclient5-jakarta-rest-client/src/main/java/org/apache/hc/client5/http/rest/RestInvocationHandler.java:
##########
@@ -184,7 +188,9 @@ private Object executeRequest(final ResourceMethod rm,
 
         final boolean isAsync = isAsync(rm.getMethod());
         final Class<?> rawType = resolveResponseType(rm.getMethod(), isAsync);
-        final Future<?> future = dispatchAsync(rawType, requestProducer);
+        final Future<?> future = isNameValuePairCollection(rm.getMethod(), isAsync)
+                ? dispatchFormResponse(requestProducer)
+                : dispatchAsync(rawType, requestProducer);

Review Comment:
   @arturobernalg This looks ugly. Are you certain we need a separate method for form data and this logic cannot be added to `dispatchAsync`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #844:
URL: https://github.com/apache/httpcomponents-client/pull/844#discussion_r3529294289


##########
httpclient5-jakarta-rest-client/src/main/java/org/apache/hc/client5/http/rest/RestInvocationHandler.java:
##########
@@ -162,19 +166,21 @@ private Object executeRequest(final ResourceMethod rm,
         for (final Header header : headers) {
             request.addHeader(header);
         }
-        final List<ContentType> consumesContentTypes = rm.getConsumesContentTypes();
-        if (consumesContentTypes != null && !consumesContentTypes.isEmpty()) {
+        // @Produces declares the media type(s) the client accepts back (Accept header).

Review Comment:
   @arturobernalg Indeed. It looks like I made a mistake here. `@Produces` declares what  the endpoint produces and what client can choose to accept. Good catch.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Added application/x-www-form-urlencoded support to the Jakarta REST client backed by a collection of NameValuePair [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #844:
URL: https://github.com/apache/httpcomponents-client/pull/844#issuecomment-4917171943

   @arturobernalg Looks good to me.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org