Skip to content

cHttpClient Methods Reference

🌐 HTTP Request Methods

SendGet

Sends GET request.

vb
Public Function SendGet(ByVal url As String, Optional Body As String) As cHttpClient

Parameters:

  • url - Request URL
  • Body - Optional, request body content

Returns: Returns self instance for chainable calls

Example:

vb
Dim http As New cHttpClient

' Simple GET
http.SendGet("https://api.example.com/users")

' GET with query parameters
http.RequestDataQuery("page") = "1"
http.RequestDataQuery("limit") = "10"
http.SendGet("https://api.example.com/users")

SendPost

Sends POST request.

vb
Public Function SendPost(ByVal url As String, Optional Body As String) As cHttpClient

Example:

vb
' POST JSON data
Dim json As New cJson
json.AddItem "name", "John"
Set http.RequestDataJson = json
http.SendPost("https://api.example.com/users")

' POST Form data
http.RequestDataForm("username") = "admin"
http.RequestDataForm("password") = "123456"
http.SendPost("https://api.example.com/login")

SendPut

Sends PUT request.

vb
Public Function SendPut(ByVal url As String, Optional Body As String) As cHttpClient

SendDelete

Sends DELETE request.

vb
Public Function SendDelete(ByVal url As String, Optional Body As String) As cHttpClient

SendOptions

Sends OPTIONS request.

vb
Public Function SendOptions(ByVal url As String, Optional Body As String) As cHttpClient

Send

General send method, specifies HTTP method.

vb
Public Function Send(Method As EnumRequestMethod, ByVal url As String, Optional Body As String) As cHttpClient

Parameters:

  • Method - Request method enum value:
    • ReqGet - GET request
    • ReqPost - POST request
    • ReqPut - PUT request
    • ReqDelete - DELETE request
    • ReqOptions - OPTIONS request

Fetch

Low-level request method, all Send series methods call this method.

vb
Public Function Fetch(Method As EnumRequestMethod, ByVal url As String, Optional Body As String) As cHttpClient

🔗 Chainable Call Methods

Async

Sets request mode to sync or async.

vb
Public Function Async(Bool As Boolean) As cHttpClient

Example:

vb
' Async request
http.Async(True).SendGet("https://api.example.com/data")

' Sync request (default)
http.Async(False).SendGet("https://api.example.com/data")

SetCookies

Sets request Cookies.

vb
Public Function SetCookies(ByVal Value As String) As cHttpClient

Example:

vb
http.SetCookies("session_id=abc123; user=admin")

SetRequestContentType

Sets request content type.

vb
Public Function SetRequestContentType(ReqType As EnumRequestContentType, Optional ContentType As String) As String

Parameters:

  • ReqType - Content type enum:
    • ReqContentTypeNone - None
    • ReqContentTypeJson - application/json
    • ReqContentTypeFormUrlencoded - application/x-www-form-urlencoded
    • ReqContentTypeFormMultipart - multipart/form-data
    • ReqContentTypeTextPlain - text/plain
    • ReqContentTypeTextHtml - text/html

Example:

vb
http.SetRequestContentType(ReqContentTypeJson)

MapRequestContentType

Content type mapping method, same as SetRequestContentType.


📤 Response Retrieval Methods

ReturnText

Gets response text content.

vb
Public Function ReturnText(Optional IsUtf8 As Boolean = True, Optional IsConvert As Boolean) As String

Parameters:

  • IsUtf8 - Whether to decode as UTF-8 (default True)
  • IsConvert - Whether to use StrConv conversion (for fixing garbled text)

Example:

vb
Dim text As String
text = http.SendGet("https://api.example.com").ReturnText()

' Handle possible garbled text
text = http.ReturnText(False, True)

ReturnJson

Gets response and parses to JSON object.

vb
Public Function ReturnJson(Optional IsUtf8 As Boolean = True, Optional IsConvert As Boolean) As cJson

Example:

vb
Dim json As cJson
Set json = http.SendGet("https://api.example.com/users").ReturnJson()

If json.HasKey("data") Then
    Debug.Print json.GetItem("data")
End If

ReturnBody

Gets raw response byte array.

vb
Public Function ReturnBody() As Byte()

Example:

vb
Dim body() As Byte
body = http.SendGet("https://api.example.com/file").ReturnBody()

ReturnStream

Gets response stream object.

vb
Public Function ReturnStream() As Variant

🛠️ Utility Methods

ShowPage

Opens URL in default browser.

vb
Public Sub ShowPage(url As String)

Example:

vb
http.ShowPage("https://www.example.com")

📊 Debug Info

DebugInfo

Gets debug info JSON object (requires DebugStart = True first).

vb
Public DebugInfo As cJson

Example:

vb
http.DebugStart = True
http.SendGet("https://api.example.com")

' View debug info
If Not http.DebugInfo.RootIsEmpty Then
    ' Root is default member, can use Json("key") directly
    Debug.Print http.DebugInfo("Request")("Url")
    Debug.Print http.DebugInfo("Response")("Status")
    Debug.Print http.DebugInfo("Error")("Description")
End If

🎯 Events

OnResponseFinished

Triggers when async request response is complete.

vb
Public Event OnResponseFinished()

Example:

vb
Private WithEvents HttpClient As cHttpClient

Private Sub Form_Load()
    Set HttpClient = New cHttpClient
End Sub

Private Sub HttpClient_OnResponseFinished()
    Debug.Print "Request complete: " & HttpClient.ReturnText()
End Sub

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation