About HttpClient (gb.net.curl) Head method

Post

Posted
Rating:
#1 (In Topic #960)
Trainee
kuramayouko is in the usergroup ‘Trainee’
I'm trying to use this Library on my code but still unable to set up the headers maybe i missed something.

Code

Dim client As New HttpClient
    Dim url As String = "https://mysite/validate.json"
    Dim headers As String[]
    
    headers.Add("accept: application/json")
    headers.Add("key: " & Me.Key)
 
    client.Async = False
    client.Timeout = 20
    client.Encoding = "utf-8"
    client.URL = url
    client.UserAgent = Me.CustomUA
    client.Debug = True
    
    client.Head(headers) '-> Error in this line. Cannot load class 'String[]] : Out of bounds
    
    client.Get

Even if I use:

Code

client.Head(["accept: application/json","key: " & Me.key])

Still get the same error.
Online now: No Back to the top

Post

Posted
Rating:
#2
Banned
you must initialize the string array first

either use…

Dim headers As New String[]
or
Dim headers As String[] = []

You must do that before you can directly use headers.Add() method.
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
kuramayouko is in the usergroup ‘Trainee’
Tried that but still get the same error i even changed the code to print all the Strings in the array

Code


Dim client As New HttpClient
    Dim url As String = "https://mysite/validate.json"
    
    Dim string As String
    Dim headers As New String[]
    
    headers.Add("accept: application/json")
    headers.Add("key: " & Me.Key)
 
   'Made a loop to show all the values from the Array, works fine
    For Each string In headers
      Print string
    Next
 
    client.Async = False
    client.Timeout = 20
    client.Encoding = "utf-8"
    client.URL = url
    client.UserAgent = Me.CustomUA
    client.Debug = True
    
    client.Head(headers) '-> Same error. Cannot load class 'String[]] : Out of bounds
    
    client.Get


And im the local variable show this

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
kuramayouko is in the usergroup ‘Trainee’
Nevermind i was using the wrong method it should be

Code

client.Get(headers)
Online now: No Back to the top
1 guest and 0 members have just viewed this.