HTTPSocket Class
Used to send and receive data via the HTTP protocol.
More information available in parent classes: TCPSocket:SocketCore:Object
Notes
Use the HTTPSocket class to send and receive data via the HTTP protocol. Since this is a subclass of the TCPSocket class, all the standard socket APIs are also available. To perform secure communications via HTTP, use the HTTPSecureSocket class instead. It is otherwise identical, except that it is subclassed from SSLSocket instead of TCPSocket. This makes all the options for encrypted communications available to HTTPSecureSocket objects.
If you use a constructor in a subclass of HTTPSocket, you must call the super class's constructor in your subclass's constructor. The subclass fail with error 107 when you try to download.
When using the optional Timeout parameter of the Get, GetHeaders, or Post methods the page will be received or posted in a synchronous manner. That is, REALbasic will wait until the page has been received or posted before it proceeds. If Timeout is set to zero, the socket will wait indefinitely or until it receives an error.
To use synchronous mode, simply pass the optional parameter. For example,
When using synchronous mode, you can set the Yield property to True to tell the socket to yield time to other events and code to execute while waiting. Simply insert a statement such as
to allow background processes to execute while waiting.
Example
The following example retrieves the specified URL:
The following example posts a simple form:
Dim socket1 as New HTTPSocket
// create and populate the form object
form = New Dictionary
form.value("firstname") = "Bob"
form.value("lastname") = "Brown"
// setup the socket to POST the form
socket1.setFormData form
socket1.post "http://www.myformlocation.com/form.php"
See Also
HTTPSecureSocket, SocketCore, TCPSocket classes.<