org.jboss.mq.il.http
public class: HTTPClient [javadoc |
source]
java.lang.Object
org.jboss.mq.il.http.HTTPClient
Utility class that provides HTTP functionality. This class is modeled after
Scott's Util class in org.jboss.invocation.http.interfaces.Util, however,
that class deals with Invocation object, while this handles HTTPILRequest
objects. Other then that, it is a pretty close reproduction.
- author:
Nathan - Phelps (nathan@jboss.org)
- version:
$ - Revision: 37459 $
- created:
January - 15, 2003
| Method from org.jboss.mq.il.http.HTTPClient Detail: |
public static Object post(URL url,
HTTPILRequest request) throws Exception {
if (log.isTraceEnabled())
{
log.trace("post(URL " + url.toString() + ", HTTPILRequest " + request.toString() + ")");
}
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
Util.configureHttpsHostVerifier(connection);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("ContentType", CONTENT_TYPE);
connection.setRequestMethod("POST");
ObjectOutputStream outputStream = new ObjectOutputStream(connection.getOutputStream());
outputStream.writeObject(request);
outputStream.close();
ObjectInputStream inputStream = new ObjectInputStream(connection.getInputStream());
HTTPILResponse response = (HTTPILResponse)inputStream.readObject();
inputStream.close();
Object responseValue = response.getValue();
if (responseValue instanceof Exception)
{
throw (Exception)responseValue;
}
return responseValue;
}
|
public static URL resolveServerUrl(String url) throws MalformedURLException {
return Util.resolveURL(url);
}
|