}
try
{
URL url = new URL(urlParam);
HTTPConnection conn = new HTTPConnection(url);
conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
conn.setAllowUserInteraction(false);
NVPair credentials = getCredentials(url);
if (credentials != null)
{
conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
}
HTTPResponse resp = null;
if (entity != null)
{
HttpOutputStream stream = new HttpOutputStream();
resp = conn.Post(url.getFile(), stream, headerPairs);
byte[] buf = new byte[1024];
int r = -1;
while ((r = entity.read(buf)) != -1)
{
stream.write(buf, 0, r);
}
stream.close();
}
else
{
resp = conn.Post(url.getFile(), (NVPair[])null, headerPairs);
}
if (resp.getStatusCode() >= 300)
{
if (LOG.isDebugEnabled())