forked from SunshineCoastCouncil/ASP.NET-Simple-Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProxy.aspx.cs
More file actions
44 lines (40 loc) · 1.35 KB
/
Proxy.aspx.cs
File metadata and controls
44 lines (40 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Web;
using System.Web.UI;
using System.Net;
using System.IO;
namespace Proxy
{
public partial class _Proxy : Page
{
protected void Page_Load(object sender, EventArgs e)
{
string proxyURL = string.Empty;
try
{
proxyURL = HttpUtility.UrlDecode(Request.QueryString["u"]);
}
catch { }
if (proxyURL != string.Empty)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(proxyURL);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode.ToString().ToLower() == "ok")
{
string contentType = response.ContentType;
Stream content = response.GetResponseStream();
BinaryReader contentReader = new BinaryReader(content);
Response.ContentType = contentType;
int bytesRead;
do
{
byte[] buffer = contentReader.ReadBytes(4096);
bytesRead = buffer.Length;
Response.BinaryWrite(buffer);
} while (bytesRead == 4096);
}
}
}
}
}