Here I am looking like following example

https://www.example.com/http://quintessentiallyme.co.uk/wp-content/uploads/2014/02/say_hello.png

I have done this following code, Here I will get site content, But I have replace image path and url path, But in my use case it wont suits, so Please provide me any solution

    public void ProcessRequest(HttpContext context)
    {
        HttpResponse response = context.Response;
        // Check for query string
        string uri = Uri.UnescapeDataString(context.Request.QueryString.ToString());
        if (string.IsNullOrWhiteSpace(uri))
        {
            response.StatusCode = 403;
            response.End();
            return;
        }

        // Filter requests
        //if (!uri.ToLowerInvariant().Contains("wikimedia.org"))
        //{
        //    response.StatusCode = 403;
        //    response.End();
        //    return;
        //}

        // Create web request
        WebRequest webRequest = WebRequest.Create(new Uri(uri));
        webRequest.Method = context.Request.HttpMethod;

        // Send the request to the server
        WebResponse serverResponse = null;
        try
        {
            serverResponse = webRequest.GetResponse();
        }
        catch (WebException webExc)
        {
            response.StatusCode = 500;
            response.StatusDescription = webExc.Status.ToString();
            response.Write(webExc.Response);
            response.End();
            return;
        }

        // Exit if invalid response
        if (serverResponse == null)
        {
            response.End();
            return;
        }

        // Configure reponse
        response.ContentType = serverResponse.ContentType;
        Stream stream = serverResponse.GetResponseStream();

        byte[] buffer = new byte[32768];
        int read = 0;

        int chunk;
        while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
        {
            read += chunk;
            if (read != buffer.Length) { continue; }
            int nextByte = stream.ReadByte();
            if (nextByte == -1) { break; }

            // Resize the buffer
            byte[] newBuffer = new byte[buffer.Length * 2];
            Array.Copy(buffer, newBuffer, buffer.Length);
            newBuffer[read] = (byte)nextByte;
            buffer = newBuffer;
            read++;
        }

        // Buffer is now too big. Shrink it.
        byte[] ret = new byte[read];
        Array.Copy(buffer, ret, read);

        response.OutputStream.Write(ret, 0, ret.Length);
        serverResponse.Close();
        stream.Close();
        response.End();
    }

Related posts

Recent Viewed