public class UrlRequestTransport extends Object implements RequestTransport
HttpURLConnection
. Details of the connection can be amended by
overriding configureConnection(HttpURLConnection)
.
This implementation only supports http
and https
URLs. It has
primitive support for recording and playing back cookies, but does not
implement expiration processing.
Developers who wish to build a more production-ready client should consider using a RequestTRansport based around Apache HttpClient instead.
RequestTransport.TransportReceiver
Constructor and Description |
---|
UrlRequestTransport(URL url)
Construct a new UrlRequestTransport.
|
Modifier and Type | Method and Description |
---|---|
protected void |
configureConnection(HttpURLConnection connection) |
Map<String,String> |
getCookies()
Provides access to the cookies that will be sent for subsequent requests.
|
void |
send(String payload,
RequestTransport.TransportReceiver receiver)
Called by the RequestFactory implementation.
|
public UrlRequestTransport(URL url)
url
- the URL to connect toIllegalArgumentException
- if the url's protocol is not http
or https
public Map<String,String> getCookies()
public void send(String payload, RequestTransport.TransportReceiver receiver)
RequestTransport
send
in interface RequestTransport
payload
- the String payloadreceiver
- the RequestTransport.TransportReceiver
instance that will receive
the payloadprotected void configureConnection(HttpURLConnection connection) throws IOException
IOException
Copyright © 2016. All rights reserved.