return true;
}
});
}
MIMEHeaderMap headerMap = m_client.getRequestHeaders();
headerMap.clear();
setHeaders(headerMap, (TransferObject)tobj.findValue(HEADERS));
if (m_channel.getAgent() != null)
{
headerMap.setDefault(HTTP.HEADER_USER_AGENT, m_channel.getAgent());
}
if (m_channel.getContentType() != null)
{
headerMap.setDefault(HTTP.HEADER_CONTENT_TYPE, m_channel.getContentType());
}
Pair req = parametrize(sURL, tobj.findValue(BODY),
(TransferObject)tobj.findValue(PARAMETERS), headerMap);
final Object body = req.getTail();
String sMethod = (String)tobj.findValue(METHOD);
if (sMethod == null)
{
if (body != null)
{
sMethod = HTTP.METHOD_POST;
}
else
{
sMethod = HTTP.METHOD_GET;
}
}
else
{
sMethod = sMethod.toUpperCase(Locale.ENGLISH);
}
sURL = (String)req.getHead();
m_sentCounter.add(1);
return (TransferObject)m_client.invoke(URIUtil.parse(sURL), sMethod,
new HTTPClient.RequestHandler()
{
public void handleRequest(HTTPClient client, OutputStream ostream) throws IOException
{
writeBody(client, ostream, body);
}
},
new HTTPClient.ResponseHandler()
{
public Object handleResponse(HTTPClient client, InputStream istream) throws IOException
{
TransferObject tobj = null;
if (bResponse || m_channel.getErrorFunction() != null)
{
tobj = new TransferObject(5);
tobj.setClassName("HTTP");
tobj.setValue(STATUS, Primitive.createInteger(m_client.getResponseStatus()));
String sMessage = m_client.getResponseMessage();
if (sMessage != null && sMessage.length() != 0)
{
tobj.setValue(MESSAGE, sMessage);
}
MIMEHeaderMap headerMap = m_client.getResponseHeaders();
String sEncoding = getEncoding(headerMap.find(HTTP.HEADER_CONTENT_TYPE), null);
if (sEncoding == null)
{
sEncoding = getEncoding(m_channel.getContentType(), DEFAULT_ENCODING);
}
if (istream == null)
{
tobj.setValue(BODY, null);
}
else
{
MIMEHeader header;
if (m_channel.getDataType() == Primitive.BINARY ||
m_channel.getDataType() == null && MIMEUtil.isBinaryMIMEType(
((header = headerMap.find(HTTP.HEADER_CONTENT_TYPE)) == null) ? null : header.getValue()))
{
tobj.setValue(BODY, new StreamInput(istream, sEncoding).getBinary());
}
else
{