龙空技术网

VB6执行Post异步请求(基于Curl库)

vb6plus 144

前言:

此刻兄弟们对“vb6升级net”大致比较着重,姐妹们都需要剖析一些“vb6升级net”的相关文章。那么小编在网络上网罗了一些关于“vb6升级net””的相关内容,希望小伙伴们能喜欢,咱们一起来了解一下吧!

VB6执行Post异步请求(基于Curl库)

HTTPClient_Asyn_Post系列函数

说明

基于Curl库,用Post方法异步请求指定网址,返回内容。

支持http和https协议。

支持gzip、deflate、br自动解压

持续使用内存会不断增长,达到一定峰值后不会继续增长,使用完后内存自动回收

支持返回响应头

支持设置超时时间

参数

HTTPClient_Asyn_New

CurlConn:Curl连接对象

HTTPClient_Asyn_Post

CurlConn:Curl连接对象

URL:网址,支持http和https

PostDatas:请求内容

RequestHeaders:向网址发起的请求头

IsUTF8:是否是UTF8编码。0-非UTF8编码,1-UTF8字符

ConnectTimeOut:连接超时时间,单位秒

TimeOut:总超时时间,单位秒

PostDataAutoEncode:是否自动编码请求内容。比如IsUTF8=1时,自动将Ansi请求字符转码为UTF8字符

ResponseAutoDecode:是否自动解码返回内容。比如IsUTF8=1时,自动将UTF8结果字符解码为Ansi字符

HTTPClient_Asyn_IsFinish

CurlConn:Curl连接对象

HTTPClient_Asyn_GetResponse

CurlConn:Curl连接对象

ResponseHeaders:请求后得到的响应头

HTTPClient_Asyn_Free

CurlConn:Curl连接对象

引用

Public Declare Function HTTPClient_Asyn_New Lib "VB6Net.dll" (ByRef CurlConn As Long) As String

Public Declare Function HTTPClient_Asyn_Post Lib "VB6Net.dll" (ByRef CurlConn As Long, ByRef URL As String, ByRef PostDatas As String, Optional ByRef RequestHeaders As String = "Content-Type:application/x-www-form-urlencoded", Optional ByVal IsUTF8 As Integer = 1, Optional ByVal ConnectTimeOut As Integer = 5, Optional ByVal TimeOut As Integer = 60, Optional ByVal PostDataAutoEncode As Integer = 1, Optional ByVal ResponseAutoDecode As Integer = 1) As String

Public Declare Function HTTPClient_Asyn_IsFinish Lib "VB6Net.dll" (ByRef CurlConn As Long) As Boolean

Public Declare Function HTTPClient_Asyn_GetResponse Lib "VB6Net.dll" (ByRef CurlConn As Long, Optional ByRef ResponseHeaders As String = "") As String

Public Declare Sub HTTPClient_Asyn_Free Lib "VB6Net.dll" (ByRef CurlConn As Long)

示例

StrResult = HTTPClient_Asyn_New(CurlConn)

If StrResult = "OK" Then

StrResult = HTTPClient_Asyn_Post(CurlConn, ";,"Type=1&Name=hahaha")

If StrResult = "OK" Then

Do While HTTPClient_Asyn_IsFinish(CurlConn) = False

DoEvents

Loop

StrResult = HTTPClient_Asyn_GetResponse(CurlConn, ResponseHeaders)

End If

HTTPClient_Asyn_Free CurlConn

End If

Text2.Text = StrResult

例子

运行结果

标签: #vb6升级net