forked from AltoForkings/roblox-stream-sniper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttp.cs
39 lines (37 loc) · 1.47 KB
/
Http.cs
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
using System.IO;
using System.Net;
namespace kk33.RbxStreamSniper
{
public class HttpHelpers
{
public static string Get(string url, string cookie = null, string ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3835.0 Safari/537.36")
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("User-Agent", ua);
if (cookie != null)
{
request.Headers.Add("Cookie", cookie);
}
request.Method = "GET";
request.AllowAutoRedirect = true;
using (var req = request.GetResponse())
using (var sr = new StreamReader(req.GetResponseStream()))
{
return sr.ReadToEnd();
}
}
public static string GetRedirectLocation(string url, string cookie = null, string ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3835.0 Safari/537.36")
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("User-Agent", ua);
if (cookie != null)
{
request.Headers.Add("Cookie", cookie);
}
request.Method = "GET";
request.AllowAutoRedirect = true;
using (var req = request.GetResponse())
return req.ResponseUri.ToString();
}
}
}