public static HttpMethodBase accessURL(URL url, String realm,
int expectedHttpCode, int type)
throws Exception
{
HttpClient httpConn = new HttpClient();
HttpMethodBase request = createMethod(url, type);
int hdrCount = null != null ? ((Header[]) null).length : 0;
for(int n = 0; n < hdrCount; n ++)
request.addRequestHeader(((Header[]) null)[n]);
try
{
log.info("Connecting to: "+ url);
String userInfo = url.getUserInfo();
if( userInfo != null )
{
UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
httpConn.getState().setCredentials(realm, url.getHost(), auth);
}
log.info("RequestURI: "+request.getURI());
int responseCode = httpConn.executeMethod(request);
String response = request.getStatusText();
log.info("responseCode="+responseCode+", response="+response);
String content = request.getResponseBodyAsString();
log.info(content);
// Validate that we are seeing the requested response code