Sixem

.NET HTTP Handler

Aug 3rd, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.88 KB | None | 0 0
  1. Imports System.Text
  2. Imports System.Net
  3. Imports System.IO
  4. Public Class HTTP_Handle
  5.     Public Shared Function HTTP_DOWNLOAD_DATA(ByVal Site As String)
  6.         Dim request As HttpWebRequest = DirectCast(WebRequest.Create(Site), HttpWebRequest)
  7.         request.CookieContainer = FrmMain.Cookie_Handler
  8.         Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
  9.         Dim reader As New StreamReader(response.GetResponseStream())
  10.         Return reader.ReadToEnd
  11.     End Function
  12.     Public Shared Function HTTP_POST_DATA(ByVal Site As String, ByVal POST As String, ByVal UserAgent As String)
  13.         Dim postData As String = POST
  14.         Dim tempCookies As New CookieContainer
  15.         Dim _Encryption As New UTF8Encoding
  16.         Dim byteData As Byte() = _Encryption.GetBytes(postData)
  17.         Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create(Site), HttpWebRequest)
  18.         postReq.Method = "POST"
  19.         If FrmMain.Proxy_Enabled = True Then
  20.             postReq.Proxy = New WebProxy(FrmMain.Proxy_IP, True)
  21.         End If
  22.         postReq.KeepAlive = True
  23.         postReq.CookieContainer = FrmMain.Cookie_Handler
  24.         postReq.ContentType = "application/x-www-form-urlencoded"
  25.         postReq.Referer = Site
  26.         postReq.UserAgent = UserAgent
  27.         postReq.ContentLength = byteData.Length
  28.         postReq.AllowAutoRedirect = False
  29.         Dim postreqstream As Stream = postReq.GetRequestStream()
  30.         postreqstream.Write(byteData, 0, byteData.Length)
  31.         postreqstream.Close()
  32.         Dim postresponse As HttpWebResponse
  33.         postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
  34.         tempCookies.Add(postresponse.Cookies)
  35.         FrmMain.Cookie_Handler = tempCookies
  36.         Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
  37.         Return (postreqreader.ReadToEnd)
  38.     End Function
  39. End Class
Advertisement
Add Comment
Please, Sign In to add comment