On Fri, 2018-10-19 at 16:02 +0200, Joan Balagueró wrote: > Hello, > > > > Just three more questions: > > > > 1. Is this the way to set a byte array to the RequestBuilder’s > entity > (using a org.apache.http.nio.entity.NByteArrayEntity)? > > > > org.apache.hc.client5.http.classic.methods.RequestBuilder.RequestBuil > der rb > = RequestBuilder.post(uri); > > org.apache.http.nio.entity.NByteArrayEntity nbae = new > NByteArrayEntity(requestBody); > > nbae.setContentType(contentType); > > rb.setEntity(nbae); > > return rb.build(); >
Do not use classic request builder. Use AsyncRequestBuilder instead. > > > > > 2. With the Async client, in order to send an async request to > be > consumed for an AsyncConsumer: > > > > HttpRequest httpRequest = this.createPostRequest(uri, > responseTimeout); > > HttpAsyncResponseConsumer<Void> harc = new ServerHttpResponse(…); > > this.objHttp.getAsyncHttpClient().execute(new > BasicAsyncRequestProducer(this.createHttpHost(uri), httpRequest), > harc, > null); > > > > What request producer must I use now? Use AsyncRequestBuilder. > > 3. Regarding to the HttpAsyncResponseConsumer, what is the > equivalent > interface in Http5 with the methods ‘responseReceived’, > ‘consumeContent’ and > ‘responseCompleted’? > #consumeResponse, #consume, #streamEnd You might find AbstractBinResponseConsumer and AbstractCharResponseConsumer useful as base classes for custom response consumers. > > > > > I have been looking at the examples, but I couldn’t find anything > similar. > This is a whole bunch of examples of all sorts. https://github.com/apache/httpcomponents-client/tree/master/httpclient5/src/examples/org/apache/hc/client5/http/examples Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
