Skip to content

JettyHttpClient

Brad Bebee edited this page Feb 13, 2020 · 1 revision

An option is provided to use the Jetty HttpClient to connect to a NanoSparqlServer rather than the Apache HttpClient.

Background

Some users have experienced connection problems with the Apache HttpClient, particularly when making multiple concurrent requests. Typically an EOFException would be thrown when trying to retrieve a response.

By using the Jetty HttpClient instead, the same test code that reliably failed now passes.

The Jetty HttpClient

There are a few differences that are worth noting.

1) The client must be started and stopped using the start() and stop() methods.

2) The access to the response stream is via a ResponseListener instance that is passed to the client.

Apache Entities

The integration is somewhat complicated by the Jetty client not implementing multipart content. The solution implemented is to define the Jetty EntityContentProvider that wraps a standard Apache Entity. In this way we can use the richer Apache content definitions and present the data to the Jetty client.

Client Scope

Clone this wiki locally