示例#1
0
        public virtual RewriterResults rewrite(sRequest request, sResponse original, MutableContent content)
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream((content.getContent().Length * 110) / 100);
            OutputStreamWriter output = new OutputStreamWriter(baos);
            String mimeType = original.getHeader("Content-Type");
            if (request.RewriteMimeType != null)
            {
                mimeType = request.RewriteMimeType;
            }
            GadgetSpec spec = null;
            if (request.Gadget != null)
            {
                spec = _specFactory.getGadgetSpec(request.Gadget.toJavaUri(), false);
            }
            if (rewrite(spec, request.getUri(),
                        content,
                        mimeType,
                        output))
            {
                content.setContent(Encoding.Default.GetString(baos.toByteArray()));
                return RewriterResults.cacheableIndefinitely();

            }

            return null;
        }
示例#2
0
 protected static void SetResponseHeaders(HttpRequestWrapper request, HttpResponse response, sResponse results)
 {
     int refreshInterval;
     if (results.isStrictNoCache())
     {
         refreshInterval = 0;
     }
     else if (request.getParameter(REFRESH_PARAM) != null)
     {
         int.TryParse(request.getParameter(REFRESH_PARAM), out refreshInterval);
     }
     else
     {
         refreshInterval = Math.Max(60 * 60, (int)(results.getCacheTtl() / 1000L));
     }
     HttpUtil.SetCachingHeaders(response, refreshInterval);
     // We're skipping the content disposition header for flash due to an issue with Flash player 10
     // This does make some sites a higher value phishing target, but this can be mitigated by
     // additional referer checks.
     if (!results.getHeader("Content-Type").ToLower().Equals("application/x-shockwave-flash"))
     {
         response.AddHeader("Content-Disposition", "attachment;filename=p.txt");
     }
 }