Hi, i'm doing a reverse proxy using streamflyer for rewrite the server urls. This is my URL rewriting code:
@Override
protected long rewriteContent(final HttpServletRequest req, final HttpServletResponse servResp,
final InputStream input,
final OutputStream output) throws IOException {
final Charset charset = Charset.forName(servResp.getCharacterEncoding());
final Server server = getServer(req);
final String contextPath = req.getContextPath();
final String proxyPath = server.getRule().backward("/");
final String ownHostName = getOwnHostName(req);
final String regex = "((https?://)([^/]+))?(" + server.getPath() + ")";
final String replacement = "$2" + ownHostName + contextPath + proxyPath;
final FastRegexModifier modifier = new FastRegexModifier(regex, CASE_INSENSITIVE | CANON_EQ, replacement);
final Reader reader = new ModifyingReader(new InputStreamReader(input, charset), modifier);
final Writer writer = new OutputStreamWriter(output, charset);
final int copied = IOUtils.copy(reader, writer);
return copied;
}
But, apparently, streamflyer doesn't process all the stream (it doesn't reached the </html> tag). Any sugestion?
Thanks.