sub classing httpsocket

  1. 4 months ago

    David C

    Jan 4 Boston, MA

    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

    @David C the url is a string contstant. EX: mySock("GET", "http://myurl.com")

    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

  2. Paul R

    Jan 4 Pre-Release Testers, Xojo Pro Kirkland, WA

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

  3. David C

    Jan 4 Boston, MA
    Edited 4 months ago

    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.

  4. Dale A

    Jan 4 San Diego, California, USA

    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.

  5. David C

    Jan 4 Boston, MA
    Edited 4 months ago

    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.

  6. Jonathan E

    Jan 4 Pre-Release Testers, Xojo Pro Las Vegas, NV

    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).

  7. Tim P

    Jan 4 Pre-Release Testers Answer Austin, TX

    @David C the url is a string contstant. EX: mySock("GET", "http://myurl.com")

    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

  8. David C

    Jan 4 Boston, MA

    tim

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

  9. David C

    Jan 4 Boston, MA

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

    Thank you

  10. Tim P

    Jan 4 Pre-Release Testers Austin, TX

    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.

  11. David C

    Jan 4 Boston, MA

    i am using Constants as strings.

or Sign Up to reply!