// Force embedded images and the like to their own domain to avoid XSS
// in gadget domains.
String msg = "Embed request for url " + getParameter(request, URL_PARAM, "") +
" made to wrong domain " + host;
logger.info(msg);
throw new GadgetException(GadgetException.Code.INVALID_PARAMETER, msg,
HttpResponse.SC_BAD_REQUEST);
}
HttpRequest rcr = buildHttpRequest(request, URL_PARAM);
if (rcr == null) {
throw new GadgetException(GadgetException.Code.INVALID_PARAMETER,
"No url paramater in request", HttpResponse.SC_BAD_REQUEST);
}
HttpResponse results = requestPipeline.execute(rcr);
if (results.isError()) {
// Error: try the fallback. Particularly useful for proxied images.
HttpRequest fallbackRcr = buildHttpRequest(request, FALLBACK_URL_PARAM);
if (fallbackRcr != null) {
results = requestPipeline.execute(fallbackRcr);
}
}
if (contentRewriterRegistry != null) {
try {
results = contentRewriterRegistry.rewriteHttpResponse(rcr, results);
} catch (RewritingException e) {
throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e,
e.getHttpStatusCode());
}
}
for (Map.Entry<String, String> entry : results.getHeaders().entries()) {