Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            ProxyServer server = new ProxyServer(context);
            if (string.IsNullOrEmpty(server.Url)) return;

            HttpWebRequest request = server.GetRequest();

            HttpWebResponse response = server.GetResponse(request);
            if (response == null) return;

            byte[] responseData = server.GetResponseStreamBytes(response);
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.ContentType = response.ContentType;
            if (response.ContentType.StartsWith("text/html"))
            {
                string html = server.UpdateHTML(responseData);
                context.Response.Write(html);
            }
            else
            {
                context.Response.OutputStream.Write(responseData, 0, responseData.Length);
            }

            server.SetContextCookies(response);

            response.Close();
            context.Response.End();
        }