📄 frmmain.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form frmMain
Caption = "HTTP查看器"
ClientHeight = 6615
ClientLeft = 60
ClientTop = 345
ClientWidth = 7560
Icon = "FrmMain.frx":0000
LinkTopic = "Form1"
ScaleHeight = 6615
ScaleWidth = 7560
StartUpPosition = 2 '屏幕中心
Begin VB.Timer Timer1
Interval = 100
Left = 3240
Top = 3120
End
Begin RichTextLib.RichTextBox Text1
Height = 3135
Left = 120
TabIndex = 9
Top = 480
Width = 7095
_ExtentX = 12515
_ExtentY = 5530
_Version = 393217
Enabled = -1 'True
ScrollBars = 3
TextRTF = $"FrmMain.frx":0442
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "FrmMain.frx":06CC
Left = 2160
List = "FrmMain.frx":06D6
Style = 2 'Dropdown List
TabIndex = 8
Top = 4320
Width = 1455
End
Begin VB.CommandButton Command3
Caption = "发送内容"
Height = 375
Left = 6360
TabIndex = 7
Top = 4320
Width = 975
End
Begin VB.CommandButton Command2
Caption = "生成HEAD"
Height = 375
Left = 5040
TabIndex = 6
Top = 4320
Width = 1095
End
Begin VB.TextBox Text3
Height = 270
Left = 1200
TabIndex = 2
Text = "192.168.1.9"
Top = 3960
Width = 6135
End
Begin VB.CommandButton Command1
Caption = "联接到主机"
Height = 375
Left = 3720
TabIndex = 1
Top = 4320
Width = 1095
End
Begin MSWinsockLib.Winsock Winsock1
Left = 3960
Top = 3120
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.TextBox Text2
Height = 1695
Left = 120
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 4680
Width = 7215
End
Begin VB.Label Label4
Caption = "状态:"
Height = 375
Left = 4320
TabIndex = 10
Top = 120
Width = 3015
End
Begin VB.Image Image1
Height = 255
Left = 0
MousePointer = 7 'Size N S
Top = 3720
Width = 7215
End
Begin VB.Label Label3
Caption = "主机返回的内容:"
Height = 255
Left = 120
TabIndex = 5
Top = 120
Width = 1935
End
Begin VB.Label Label2
Caption = "所要提交的内容:方法:"
Height = 255
Left = 120
TabIndex = 4
Top = 4320
Width = 2295
End
Begin VB.Label Label1
Caption = "联接或HTTP:"
Height = 375
Left = 120
TabIndex = 3
Top = 3960
Width = 1215
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ifCommand2 As Boolean
Private Sub Command1_Click()
On Error GoTo LabelError
Dim strHttp As String, strHost As String
strHttp = UCase(Text3.Text)
If Winsock1.State <> 0 Then Winsock1.Close
If Text3 <> "" Then
If Left(strHttp, 7) = "HTTP://" Then
strHttp = Right(strHttp, Len(strHttp) - 7)
End If
If InStr(1, strHttp, "/") > 0 Then
strHost = Left(strHttp, InStr(1, strHttp, "/") - 1)
Else
strHost = strHttp
End If
If InStr(1, strHost, ":") Then
Winsock1.RemoteHost = Left(strHost, InStr(1, strHost, ":") - 1)
Winsock1.RemotePort = Right(strHost, Len(strHost) - InStr(1, strHost, ":"))
Else
Winsock1.RemoteHost = strHost
Winsock1.RemotePort = 80
End If
Winsock1.Connect
End If
Exit Sub
LabelError:
MsgBox Error
End Sub
Private Sub Command2_Click()
Dim strHttp As String
strHttp = Text3.Text
If Text3 <> "" Then
If UCase(Left(strHttp, 7)) = "HTTP://" Then
strHttp = Right(strHttp, Len(strHttp) - 7)
End If
SetSendData strHttp
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
Text1.Text = ""
Winsock1.SendData Text2.Text
If Err <> 0 Then MsgBox Error
End Sub
Private Sub Form_Load()
Combo1.Text = Combo1.List(0)
End Sub
Private Sub Form_Resize()
On Error Resume Next
Text1.Width = Me.Width - 360
Text2.Width = Me.Width - 360
Text3.Width = Me.Width - 1400
Image1.Width = Me.Width
Label4.Left = Me.Width - Label4.Width - 120
Text1.Height = Image1.Top - Text1.Top
Text3.Top = Image1.Top + Image1.Height
Label1.Top = Text3.Top
Label2.Top = Label1.Top + Label1.Height + 120
Combo1.Top = Label2.Top
Command1.Top = Label2.Top
Command2.Top = Label2.Top
Command3.Top = Label2.Top
Text2.Top = Label2.Top + Label2.Height + 120
Text2.Height = Me.Height - Text2.Top - 400
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If (Y > 0 And Text2.Height > 2400) Or (Y < 0 And Text1.Height > 2400) Then
Image1.Top = Image1.Top + Y
Form_Resize
End If
End If
End Sub
Private Sub Text2_Change()
If Left(Text2.Text, 4) = "POST" And ifCommand2 = False Then
endstr = vbCrLf + vbCrLf
a = InStr(1, Text2.Text, endstr) + Len(endstr)
If Text2.SelStart < a Then Exit Sub
ll = LenB(StrConv(Text2.Text, vbFromUnicode)) - a + 1
length = "Content-Length: "
b = InStr(1, Text2.Text, length) + Len(length)
oldsel = Text2.SelStart
ifCommand2 = True
e = InStr(b, Text2.Text, vbCrLf) + 1
Text2.SelStart = b
Text2.SelLength = e - b
Text2.SelText = CStr(ll) + vbCrLf
Text2.SelStart = oldsel + Len(CStr(ll) + vbCrLf) - e + b
ifCommand2 = False
End If
End Sub
Private Sub Timer1_Timer()
Dim iState As String
iState = "状态:"
Select Case Winsock1.State
Case 0
iState = iState + "已经关闭"
Case 1
iState = iState + "已经打开"
Case 2
iState = iState + "正在侦听"
Case 3
iState = iState + "连接挂起"
Case 4
iState = iState + "正在识别主机"
Case 5
iState = iState + "已经识别主机"
Case 6
iState = iState + "正在连接"
Case 7
iState = iState + "已连接到主机"
Case 8
iState = iState + "同级人员正在关闭连接"
Winsock1.Close
Case 9
iState = iState + "发生错误"
End Select
Label4.Caption = iState
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData
'If Left(strData, 2) = vbCrLf Then
' MsgBox strData
'End If
Text1.Text = Text1.Text + strData
'MsgBox strData, , Len(strData)
End Sub
Sub SetSendData(strData As String)
ifCommand2 = True
Dim strGet As String
Text2.Text = Combo1.Text + " "
If InStr(1, strData, "/") > 0 Then
strGet = Right(strData, Len(strData) - InStr(1, strData, "/") + 1)
If InStr(1, strGet, ".") = 0 And Right(strGet, 1) <> "/" Then strGet = strGet + "/"
Else
strGet = "/"
End If
Text2.Text = Text2.Text + strGet + " HTTP/1.1" + vbCrLf
Text2.Text = Text2.Text + "Accept: *.*"
Text2.Text = Text2.Text + vbCrLf + "Accept-Language: zh-cn"
Text2.Text = Text2.Text + vbCrLf + "Accept-Encoding: gzip , deflate"
Text2.Text = Text2.Text + vbCrLf + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
Text2.Text = Text2.Text + vbCrLf + "Host:" & Winsock1.RemoteHost & ":" & Winsock1.RemotePort
If Combo1.Text = "POST" Then
Text2.Text = Text2.Text + vbCrLf + "Content-Type: application/x-www-form-urlencoded" + vbCrLf + "Content-Length: "
End If
Text2.Text = Text2.Text + vbCrLf + "Connection: Keep -Alive" + vbCrLf + vbCrLf
ifCommand2 = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -