sub classing httpsocket

i’m having an issue setting up a sub class for HttpSocket.
my purpose is to call a URL and get the Content returned in to a string.

i set up a class and named it HTTPGetPage and set the super class to "Xojo.Net.HTTPSocket, then set up an event “PageReceived” for the class.
elsewhere i set up a button click;
Dim Sock As HTTPGetPage
Sock.Get(url)

i get an error stating that sock has no method “GET” — under HTTPSocket it should have this method.

also if anyone has an easier way of calling a URL and downloading content ( without having to save it to a folder ) I’m all ears.

please advise

Dave

Xojo.net.HTTPSocket does not have a Get method. That is in the older HTTPSocket. You need to use Send(“GET”, url).

dim mySock As HTTPGetPage
mySock.Send(“GET”, url) <<<< error on this line

i am receiving an error:
There is more than one item with this name and it’s not clear to which this refers.

please advise.

You’re trying to mix new and old systyems. Use

Dim mySock As Xojo.net.HTTPSocket mySock.Send("GET", url)

and get the returned data in the PageReceived handler of the instance of the socket.

i have assigned HTTPGetPage class with the super class of Xojo.Net.HTTPSocket

Dim mySock As HTTPGetPage
or
Dim mySock As Xojo.Net.HTTPSocket

the error produces in both cases.

the url is a string contstant. EX: mySock(“GET”, “http://myurl.com”)
I am handling the “PageReceived” event. but there is no errors in this event.

Can you post an example app? Also, are you using

Dim mySock as HTTPGetPage or Dim mySock as New HTTPGetPage?

The former would raise a NilObjectException because you must call the constructor for Xojo.Net.HTTPSocket (or any subclass thereof).

Xojo.Net.HTTPSocket does not accept Strings. What you’ve got written there are literals, which the compiler will handle for you, but if you have a constant you need to make sure it’s the right type.

Here’s the documentation: http://docs.xojo.com/Xojo.Net.HTTPSocket

tim

how about if i am using variables or controls IE
“http://” + domain.text + “/” ect …

yep your right i had to convert controls or constants via .ToText.

Thank you

If you’re not using the constants as strings anywhere, you should be able to set the type to Text and skip the constant.ToText step.

i am using Constants as strings.