public class DefaultHttpService extends AbstractContexed implements AppContextService<HttpService>, HttpService
HttpService
This uses the most basic functionality provided in the base java classes and requires no new dependencies.
More advanced implementations using dedicated client libraries can be substituted if these are not sufficientconn
Constructor and Description |
---|
DefaultHttpService(AppContext conn) |
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
AppContext is being closed. |
protected java.net.HttpURLConnection |
connect(java.net.URL url)
extension point to allow mock insertion
|
MimeStreamData |
fetch(java.net.URL url,
java.util.Map<java.lang.String,java.lang.String> props)
fetch data from a URL
|
MimeStreamData |
post(java.net.URL url,
java.util.Map<java.lang.String,java.lang.String> props,
MimeStreamData input)
post data to a URL
This is intended to post a single object rather than encoded form data.
|
getContext, getLogger, resetLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addBasicAuth, getType
public DefaultHttpService(AppContext conn)
public void cleanup()
AppContextCleanup
AppContext
is being closed.
Only use this for cleanup that can't be handled by
normal garbage collection or for state which is never returned by reference.cleanup
in interface AppContextCleanup
public MimeStreamData fetch(java.net.URL url, java.util.Map<java.lang.String,java.lang.String> props) throws HttpException
HttpService
fetch
in interface HttpService
url
- URL to fetch fromprops
- additional request headers to setMimeStreamData
HttpException
protected java.net.HttpURLConnection connect(java.net.URL url) throws java.io.IOException
url
- java.io.IOException
public MimeStreamData post(java.net.URL url, java.util.Map<java.lang.String,java.lang.String> props, MimeStreamData input) throws HttpException
HttpService
post
in interface HttpService
url
- URL to post toprops
- additional request headers to setinput
- MimeStreamData
to postMimeStreamData
HttpException