Skip to content

cHttpClient Properties Reference

📝 Request Data Properties

RequestDataJson

Sets JSON format request body data.

vb
Public RequestDataJson As New cJson

Description: When this property is set and Content-Type is JSON, the request body will be automatically serialized to JSON string.

Example:

vb
Dim http As New cHttpClient
Dim json As New cJson

json.AddItem "username", "admin"
json.AddItem "password", "123456"

Set http.RequestDataJson = json
http.SendPost("https://api.example.com/login")

RequestDataForm

Sets Form format request body data (form data).

vb
Public RequestDataForm As New Scripting.Dictionary

Description: Suitable for application/x-www-form-urlencoded type requests.

Example:

vb
Dim http As New cHttpClient

http.RequestDataForm("username") = "admin"
http.RequestDataForm("password") = "123456"
http.RequestDataForm("remember") = "true"

http.SendPost("https://api.example.com/login")

RequestDataQuery

Sets URL query parameters.

vb
Public RequestDataQuery As New Scripting.Dictionary

Description: Will be automatically appended to URL when sending request.

Example:

vb
Dim http As New cHttpClient

http.RequestDataQuery("page") = "1"
http.RequestDataQuery("limit") = "20"
http.RequestDataQuery("sort") = "desc"

' Final URL: https://api.example.com/users?page=1&limit=20&sort=desc
http.SendGet("https://api.example.com/users")

RequestDataBody

Deprecated - Please use RequestDataForm instead.


📋 Request Configuration Properties

RequestHeaders

Sets custom request headers.

vb
Public RequestHeaders As New Scripting.Dictionary

Example:

vb
Dim http As New cHttpClient

http.RequestHeaders("Authorization") = "Bearer token123"
http.RequestHeaders("X-Custom-Header") = "custom-value"
http.RequestHeaders("User-Agent") = "MyApp/1.0"

http.SendGet("https://api.example.com/protected")

RequestContentType

Sets request content type.

vb
Public RequestContentType As String

Common Values:

  • application/json - JSON data
  • application/x-www-form-urlencoded - Form data (default)
  • multipart/form-data - File upload
  • text/plain - Plain text
  • text/html - HTML content

Example:

vb
Dim http As New cHttpClient
http.RequestContentType = "application/json"
' Or use convenience method
http.SetRequestContentType(ReqContentTypeJson)

RequestChartSet

Sets request encoding.

vb
Public RequestChartSet As String

Default: utf-8

Description: Affects request body encoding. When set to UTF-8, will use UTF-8 encoding.


RequestTimeOut

Sets request timeout (seconds).

vb
Public RequestTimeOut As Long

Default: 30 seconds

Description: Only used in sync request mode.

Example:

vb
Dim http As New cHttpClient
http.RequestTimeOut = 60  ' 60 seconds timeout
http.SendGet("https://api.example.com/slow-api")

📥 Response Data Properties

ResponseRaw

Cached raw response content.

vb
Public ResponseRaw As Variant

ResponseHeaders

Response headers dictionary.

vb
Public ResponseHeaders As New Scripting.Dictionary

Example:

vb
Dim http As New cHttpClient
http.SendGet("https://api.example.com")

' Get response header
If http.ResponseHeaders.Exists("Content-Type") Then
    Debug.Print "Content-Type: " & http.ResponseHeaders("Content-Type")
End If

' Iterate all response headers
Dim key As Variant
For Each key In http.ResponseHeaders.Keys
    Debug.Print key & ": " & http.ResponseHeaders(key)
Next

Cookies

Parsed Cookies dictionary.

vb
Public Cookies As New Scripting.Dictionary

Description: Auto parsed from response header Set-Cookie.

Example:

vb
Dim http As New cHttpClient
http.SendGet("https://api.example.com/login")

' Get Cookie
If http.Cookies.Exists("session_id") Then
    Debug.Print "Session ID: " & http.Cookies("session_id")
End If

' Carry Cookie in next request
http.SetCookies("session_id=" & http.Cookies("session_id"))
http.SendGet("https://api.example.com/profile")

⚙️ Debug Properties

DebugStart

Enables debug mode.

vb
Public DebugStart As Boolean

Description: After setting to True, DebugInfo property will be populated after request completes.

Example:

vb
Dim http As New cHttpClient
http.DebugStart = True

On Error Resume Next
http.SendGet("https://api.example.com")

' View debug info
If http.DebugInfo.HasKey("Error") Then
    Debug.Print "Error: " & http.DebugInfo.GetItem("Error").GetItem("Description")
End If

LastError

Last error message.

vb
Public LastError As String

Example:

vb
Dim http As New cHttpClient
Dim success As Boolean

On Error Resume Next
success = http.SendGet("https://invalid-url").ReturnText() <> ""

If Not success Then
    Debug.Print "Request failed: " & http.LastError
End If

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation