Package nl.b3p.brmo.util.http.wrapper
Class URLConnectionHttpClientWrapper
java.lang.Object
nl.b3p.brmo.util.http.wrapper.URLConnectionHttpClientWrapper
- All Implemented Interfaces:
HttpClientWrapper<HttpURLConnection,
HttpURLConnection>
public class URLConnectionHttpClientWrapper
extends Object
implements HttpClientWrapper<HttpURLConnection,HttpURLConnection>
Wraps a standard Java HttpURLConnection or HttpsURLConnection.
- Author:
- Matthijs Laan
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
beforeRequest
(HttpURLConnection httpURLConnection) Called before doing a request, override to modify or log it.Perform a synchronous HTTP GET request.wrapResponse
(HttpURLConnection httpURLConnection) Wraps a HttpURLConnection after HttpURLConnection.connect() has been called, override to modify or log it.
-
Constructor Details
-
URLConnectionHttpClientWrapper
public URLConnectionHttpClientWrapper()
-
-
Method Details
-
request
Description copied from interface:HttpClientWrapper
Perform a synchronous HTTP GET request.- Specified by:
request
in interfaceHttpClientWrapper<HttpURLConnection,
HttpURLConnection> - Parameters:
uri
- The URI.requestHeaders
- The request headers to send. The supplied String instances must alternate as header names and header values. Only single request header values are expected.- Returns:
- A wrapper with the response.
- Throws:
IOException
- If an I/O error occurs.
-
beforeRequest
Called before doing a request, override to modify or log it.- Specified by:
beforeRequest
in interfaceHttpClientWrapper<HttpURLConnection,
HttpURLConnection> - Parameters:
httpURLConnection
- The HttpURLConnection that will be used, can be modified
-
wrapResponse
Wraps a HttpURLConnection after HttpURLConnection.connect() has been called, override to modify or log it.- Specified by:
wrapResponse
in interfaceHttpClientWrapper<HttpURLConnection,
HttpURLConnection> - Parameters:
httpURLConnection
- The URL connection to be wrapped- Returns:
- The wrapped response
-