The httprequest module allows you to perform http requests such as GET and POST. More...
Constructors: | |
Methods: |
|
Import
mojo
Import
brl.httprequest
Class
MyApp
Extends
App
Implements
IOnHttpRequestComplete
Field
get_req
:
HttpRequest
,
post_req
:
HttpRequest
Method
OnHttpRequestComplete
:
Void
(
req
:
HttpRequest
)
If
req
=
get_req
Print
"Http GET complete!"
Else
Print
"Http POST complete!"
Endif
Print
"Status="
+
req.Status
()
Print
"ResponseText="
+
req.ResponseText
()
End
Method
OnCreate
()
get_req
=
New
HttpRequest
(
"GET"
,
"http://posttestserver.com"
,
Self
)
get_req.Send
post_req
=
New
HttpRequest
(
"POST"
,
"http://posttestserver.com/post.php"
,
Self
)
post_req.Send
"Hello World!"
SetUpdateRate
60
End
Method
OnUpdate
()
If
KeyHit
(
KEY_CLOSE
)
Error
""
UpdateAsyncEvents
End
Method
OnRender
()
Cls
DrawText
"Http GET bytes received="
+
get_req.BytesReceived
(),
0
,
0
DrawText
"Http POST bytes received="
+
post_req.BytesReceived
(),
0
,
12
End
End
Function
Main
()
New
MyApp
End
Creates a new http request object and opens it.
The requestMethod parameter should be GET, HEAD, POST, PUT, DELETE or any http method recognized by the server.
See also Open
Opens an http request.
This effectively 'resets' the internal state of the http request.
The requestMethod parameter should be GET, HEAD, POST, PUT, DELETE or any http method recognized by the server.
The response text returned by the server once the request has completed.
Sends an http request.
Once complete, the OnHttpRequestComplete method of the IOnHttpRequestComplete object passed to the construtor will be called.
Your application must continously call UpdateAsyncEvents at regular intervals (for example, once per OnUpdate) while an http request operation is in progress.
Sends an http request with data.
Send sets the request's Content-Length header to the encoded length of data.
If mimeType is not an empty string, Send also sets the request Content-Type header.
Once complete, the OnHttpRequestComplete method of the IOnHttpRequestComplete object passed to the construtor will be called.
Your application must continously call UpdateAsyncEvents at regular intervals (for example, once per OnUpdate) while an http request operation is in progress for it to complete.