final Lookup paramMap = (isMultipart()) ? getMultipartParameters(null, 0) : null;
m_bURLEncoded = (getParameter("url-encoded") != null || paramMap != null && paramMap.get("url-encoded") != null);
m_response.setContentType((m_bURLEncoded) ? "text/plain; charset=UTF-8" : m_sContentType);
CharacterStreamServer server = (CharacterStreamServer)m_server.getInstance(m_context);
if (server instanceof HTTPServer)
{
((HTTPServer)server).invoke(m_servlet, m_request, m_response);
}
if (paramMap != null)
{
Object req = paramMap.get("request");
if (!(req instanceof String[]) || ((String[])req).length != 1)
{
throw new RequestException("err.rpc.attachment");
}
req = ((String[])req)[0];
if (m_bURLEncoded)
{
req = URLDecoder.decode((String)req, m_request.getCharacterEncoding());
}
// Enhance the request with data from parameters "file-<argIndex>-<dataAttr>-<fileNameAttr>"
server.invoke(new StringReader((String)req), getWriter(), new Preprocessor()
{
public void preprocess(Request request)
{
addMultipartData(request, paramMap);
}
});
}
else
{
server.invoke(getReader(), getWriter(), null);
}
}