Skip to content

Commit 6834b82

Browse files
committed
Added support for reading from stream and added async IP query
1 parent 4697ad9 commit 6834b82

22 files changed

+1827
-2171
lines changed
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29728.190
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "IP2ProxyComponent", "IP2ProxyComponent\IP2ProxyComponent.vbproj", "{7657143A-0A25-4A75-BAA8-970B3438BA1F}"
7-
EndProject
8-
Global
9-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|Any CPU = Debug|Any CPU
11-
Release|Any CPU = Release|Any CPU
12-
EndGlobalSection
13-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Release|Any CPU.Build.0 = Release|Any CPU
18-
EndGlobalSection
19-
GlobalSection(SolutionProperties) = preSolution
20-
HideSolutionNode = FALSE
21-
EndGlobalSection
22-
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {93F832FE-2D37-4A76-9177-28B5868CD4B7}
24-
EndGlobalSection
25-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29728.190
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "IP2ProxyComponent", "IP2ProxyComponent\IP2ProxyComponent.vbproj", "{7657143A-0A25-4A75-BAA8-970B3438BA1F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7657143A-0A25-4A75-BAA8-970B3438BA1F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {93F832FE-2D37-4A76-9177-28B5868CD4B7}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
Imports System.Net
2-
Imports System.Text
3-
4-
Public Class Http
5-
Public Function GetMethod(ByVal url As String) As String
6-
Dim request As HttpWebRequest
7-
Dim response As HttpWebResponse
8-
request = WebRequest.Create(url)
9-
request.Method = "GET"
10-
response = request.GetResponse()
11-
If response.StatusCode = HttpStatusCode.OK Then
12-
Dim reader As New IO.StreamReader(response.GetResponseStream())
13-
Dim raw As String = reader.ReadToEnd
14-
Return raw
15-
Else
16-
Return ("Failed : HTTP error code :" & response.StatusCode)
17-
End If
18-
End Function
19-
20-
Public Function PostMethod(ByVal url As String, post As String) As String
21-
Dim request As HttpWebRequest
22-
Dim response As HttpWebResponse
23-
Dim encode As UTF8Encoding
24-
Dim postdata As String = post
25-
Dim postdatabytes As Byte()
26-
27-
request = WebRequest.Create(url)
28-
encode = New UTF8Encoding()
29-
postdatabytes = encode.GetBytes(postdata)
30-
request.Method = "POST"
31-
request.ContentType = "application/x-www-form-urlencoded"
32-
request.ContentLength = postdatabytes.Length
33-
34-
Using stream = request.GetRequestStream
35-
stream.Write(postdatabytes, 0, postdatabytes.Length)
36-
End Using
37-
response = request.GetResponse()
38-
If response.StatusCode = HttpStatusCode.OK Then
39-
Dim reader As New IO.StreamReader(response.GetResponseStream())
40-
Dim raw As String = reader.ReadToEnd
41-
Return raw
42-
Else
43-
Return ("Failed : HTTP error code :" & response.StatusCode)
44-
End If
45-
End Function
1+
Imports System.Net
2+
Imports System.Text
3+
4+
Public Class Http
5+
Public Shared Function GetMethod(url As String) As String
6+
Dim request As HttpWebRequest
7+
Dim response As HttpWebResponse
8+
request = WebRequest.Create(url)
9+
request.Method = "GET"
10+
response = request.GetResponse()
11+
If response.StatusCode = HttpStatusCode.OK Then
12+
Dim reader As New IO.StreamReader(response.GetResponseStream())
13+
Dim raw As String = reader.ReadToEnd
14+
Return raw
15+
Else
16+
Return ("Failed : HTTP error code :" & response.StatusCode)
17+
End If
18+
End Function
19+
20+
Public Shared Function PostMethod(url As String, post As String) As String
21+
Dim request As HttpWebRequest
22+
Dim response As HttpWebResponse
23+
Dim encode As UTF8Encoding
24+
Dim postdata As String = post
25+
Dim postdatabytes As Byte()
26+
27+
request = WebRequest.Create(url)
28+
encode = New UTF8Encoding()
29+
postdatabytes = encode.GetBytes(postdata)
30+
request.Method = "POST"
31+
request.ContentType = "application/x-www-form-urlencoded"
32+
request.ContentLength = postdatabytes.Length
33+
34+
Using stream = request.GetRequestStream
35+
stream.Write(postdatabytes, 0, postdatabytes.Length)
36+
End Using
37+
response = request.GetResponse()
38+
If response.StatusCode = HttpStatusCode.OK Then
39+
Dim reader As New IO.StreamReader(response.GetResponseStream())
40+
Dim raw As String = reader.ReadToEnd
41+
Return raw
42+
Else
43+
Return ("Failed : HTTP error code :" & response.StatusCode)
44+
End If
45+
End Function
4646
End Class

0 commit comments

Comments
 (0)