HttpFetch
From Pointui
Fetches the contents of a URL.
Contents |
Events
void OnComplete()
Triggered when the download of the URL has completed either because it was successful or because it failed. Typically GetContent() is called in the OnComplete() handler to see what was downloaded.
void OnConnectionFailed()
AVAILABLE SINCE: 2.0.22b Raised when a connection can't be made for the request.
void OnConnected()
AVAILABLE SINCE: 2.0.22b Raised when a connection has been established, just before the request is sent.
void OnContentLengthKnown(int contentLength)
AVAILABLE SINCE: 2.0.22b Raised when the server has provided a content-length header in it's response and enough of the response has been received to parse the header.
Methods
void Start(String url, String submitType)
void Start(HttpRequest request)
Starts downloading from the url or request (HttpRequest AVAILABLE SINCE: 2.0.22b) supplied.
EXAMPLE
class ScreenExample : Screen { HttpFetch newsRssFetch; void Load() { //set the event handler newsRssFetch.OnComplete = newsRssFetch_OnComplete; //start downloading newsRssFetch.Start("http://somenewsurl.com/etc"); } //handler void newsRssFetch_OnComplete() { //get the content that was downloaded String rss; newsRssFetch.GetContent(rss); //was there anything? if (newsReport.GetLength() > 0) { //save to the file system so we can use it later if have no connection File.Write(newsFilename, newsReport); //now parse it… } } }
void GetContent(String resultContent)
Gets the downloaded data from the url and copies it into the resultContent variable.
void SaveResponseToFile(String filename)
AVAILABLE SINCE: 2.0.22b Saves the entire response content to a file. This is useful for when downloading binary resources such as images.
int GetResponseStatusCode()
AVAILABLE SINCE: 2.0.22b Returns the status code for the response.
