Class ClientUtils
java.lang.Object
org.opengis.cite.ogcapiprocesses20.util.ClientUtils
Provides various utility methods for creating and configuring HTTP client components.
- Author:
- bpr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.http.client.HttpClientBuilds a client component for interacting with HTTP endpoints.static DocumentgetResponseEntityAsDocument(org.glassfish.jersey.client.ClientResponse response, String targetURI) Obtains the (XML) response entity as a DOM Document and resets the entity input stream for subsequent reads.static SourcegetResponseEntityAsSource(org.glassfish.jersey.client.ClientResponse response, String targetURI) Obtains the (XML) response entity as a JAXP Source object and resets the entity input stream for subsequent reads.static booleanis200Response(URI uri) Checks if a GET request to a given URI returns HTTP 200 - OK
-
Constructor Details
-
ClientUtils
public ClientUtils()
-
-
Method Details
-
buildClient
public static org.apache.http.client.HttpClient buildClient()Builds a client component for interacting with HTTP endpoints. The client will automatically redirect to the URI declared in 3xx responses. The connection timeout is 10 s. Request and response messages may be logged to a JDK logger (in the namespace "com.sun.jersey.api.client").- Returns:
- A Client component.
-
getResponseEntityAsSource
public static Source getResponseEntityAsSource(org.glassfish.jersey.client.ClientResponse response, String targetURI) Obtains the (XML) response entity as a JAXP Source object and resets the entity input stream for subsequent reads.- Parameters:
response- A representation of an HTTP response message.targetURI- The target URI from which the entity was retrieved (may be null).- Returns:
- A Source to read the entity from; its system identifier is set using the given targetURI value (this may be used to resolve any relative URIs found in the source).
-
getResponseEntityAsDocument
public static Document getResponseEntityAsDocument(org.glassfish.jersey.client.ClientResponse response, String targetURI) Obtains the (XML) response entity as a DOM Document and resets the entity input stream for subsequent reads.- Parameters:
response- A representation of an HTTP response message.targetURI- The target URI from which the entity was retrieved (may be null).- Returns:
- A Document representing the entity; its base URI is set using the given targetURI value (this may be used to resolve any relative URIs found in the document).
-
is200Response
Checks if a GET request to a given URI returns HTTP 200 - OK- Parameters:
uri- The URI to check- Returns:
- true, if HTTP 200 - OK was returned after a GET request, false otherwise
- Since:
- 1.3
-