HTTP 请求测试工具 - XIN.

HTTP 请求测试工具

  in   tech with  0  comment

调试一个请求,百度了半天没找到合适的工具。突然想起来很久之前用VB写过半个类似的测试工具。好像已经好几年没碰过VB了,顺便练练手。于是就找出来重新写了一遍。

不得不说,VB确实不能适应现在的开发环境,许多现在必要的方法都没有封装。也不能怪语言,只怪微软不支持

附上一个 UTF-8 转 Unicode 的模块

    Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
    Private Const CP_UTF8 = 65001
    
    'Purpose:Convert Utf8 to Unicode
    Public Function UTF8_Decode(ByVal sUTF8 As String) As String
       Dim lngUtf8Size      As Long
       Dim strBuffer        As String
       Dim lngBufferSize    As Long
       Dim lngResult        As Long
       Dim bytUtf8()        As Byte
       Dim n                As Long
       If LenB(sUTF8) = 0 Then Exit Function
          On Error GoTo EndFunction
          bytUtf8 = StrConv(sUTF8, vbFromUnicode)
          lngUtf8Size = UBound(bytUtf8) + 1
          On Error GoTo 0
          lngBufferSize = lngUtf8Size * 2
          strBuffer = String$(lngBufferSize, vbNullChar)
          'Translate using code page 65001(UTF-8)
          lngResult = MultiByteToWideChar(CP_UTF8, 0, bytUtf8(0), _
             lngUtf8Size, StrPtr(strBuffer), lngBufferSize)
          'Trim result to actual length
          If lngResult Then
             UTF8_Decode = Left$(strBuffer, lngResult)
          End If
    EndFunction:
    End Function

github地址: https://github.com/lscho/http_test

下载地址

Responses