You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/03/08 13:57:24 UTC

[GitHub] [camel-quarkus] tsegismont commented on a change in pull request #3597: Add Azure Core HTTP Client Vert.x extension

tsegismont commented on a change in pull request #3597:
URL: https://github.com/apache/camel-quarkus/pull/3597#discussion_r821686740



##########
File path: extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/BufferedVertxHttpResponse.java
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.support.azure.core.http.vertx;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+import com.azure.core.http.HttpRequest;
+import com.azure.core.http.HttpResponse;
+import io.vertx.core.buffer.Buffer;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+public final class BufferedVertxHttpResponse extends VertxHttpAsyncResponse {
+
+    private final Buffer body;
+
+    BufferedVertxHttpResponse(HttpRequest request, io.vertx.ext.web.client.HttpResponse response, Buffer body) {
+        super(request, response);
+        this.body = body;

Review comment:
       I would not recommend to use pipe with a custom implementation of `WriteStream`. If you face the need to do this, it means that you should probably be using the raw `HttpClient` which is more flexible than the `WebClient` in this area.
   
   One thing you need to know about the `pipe` body codec: it is only when the whole content has been read that the `WebClient.send` callback is invoked. So you can't, for example, inspect the HTTP status code or headers before deciding what to do with the content.
   
   I you choose to go the `HttpClient` route, I think there are examples in the Vert.x docs for consumption of HTTP bodies.

##########
File path: extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/BufferedVertxHttpResponse.java
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.support.azure.core.http.vertx;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+import com.azure.core.http.HttpRequest;
+import com.azure.core.http.HttpResponse;
+import io.vertx.core.buffer.Buffer;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+public final class BufferedVertxHttpResponse extends VertxHttpAsyncResponse {
+
+    private final Buffer body;
+
+    BufferedVertxHttpResponse(HttpRequest request, io.vertx.ext.web.client.HttpResponse response, Buffer body) {
+        super(request, response);
+        this.body = body;

Review comment:
       I would not recommend to use `pipe` with a custom implementation of `WriteStream`. If you face the need to do this, it means that you should probably be using the raw `HttpClient` which is more flexible than the `WebClient` in this area.
   
   One thing you need to know about the `pipe` body codec: it is only when the whole content has been read that the `WebClient.send` callback is invoked. So you can't, for example, inspect the HTTP status code or headers before deciding what to do with the content.
   
   I you choose to go the `HttpClient` route, I think there are examples in the Vert.x docs for consumption of HTTP bodies.




-- 
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: commits-unsubscribe@camel.apache.org

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