UrlLoader.new: Difference between revisions
From GiderosMobile
No edit summary |
mNo edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 5: | Line 5: | ||
=== Description === | === Description === | ||
Creates a new '''UrlLoader''' object. | Creates a new '''UrlLoader''' object. | ||
< | <syntaxhighlight lang="lua"> | ||
UrlLoader.new(url,method,headers,body) | UrlLoader.new(url,method,headers,body) | ||
</ | </syntaxhighlight> | ||
| Line 24: | Line 24: | ||
=== Examples === | === Examples === | ||
< | <syntaxhighlight lang="lua"> | ||
local url = "http://www.[yourDomain].com/application.php?userid=gideros&login=guest" | local url = "http://www.[yourDomain].com/application.php?userid=gideros&login=guest" | ||
| Line 38: | Line 38: | ||
} | } | ||
local loader6 = UrlLoader.new(url, UrlLoader.PUT, headers, "key=value") | local loader6 = UrlLoader.new(url, UrlLoader.PUT, headers, "key=value") | ||
</ | </syntaxhighlight> | ||
{{UrlLoader}} | {{UrlLoader}} | ||
Latest revision as of 09:44, 27 July 2026
Available since: Gideros 2012.2.2
Class: UrlLoader
Description
Creates a new UrlLoader object.
UrlLoader.new(url,method,headers,body)
method parameter specifies the HTTP request method. It can be one of the values of UrlLoader.GET, UrlLoader.POST, UrlLoader.PUT or UrlLoader.DELETE. The default HTTP method is UrlLoader.GET
body parameter specifies the HTTP body data. This parameter is used only when the HTTP method is UrlLoader.POST or UrlLoader.PUT
After loading is finished, loaded data is stored as a string in the event.data field of Event.COMPLETE event.
Parameters
url: (string, optional) URL to download. This parameter is optional and if specified loading starts immediately
method: (string, default = "get") HTTP request method
headers: (table, optional) HTTP headers
body: (string, optional) HTTP body data. This data is sent as the message body of a request
Examples
local url = "http://www.[yourDomain].com/application.php?userid=gideros&login=guest"
local loader1 = UrlLoader.new(url)
local loader2 = UrlLoader.new(url, UrlLoader.GET) -- same as the previous line
local loader3 = UrlLoader.new(url, UrlLoader.POST, "my post data")
local loader4 = UrlLoader.new(url, UrlLoader.PUT, "my put data")
local loader5 = UrlLoader.new(url, UrlLoader.DELETE)
local headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["User-Agent"] = "Gideros Browser",
}
local loader6 = UrlLoader.new(url, UrlLoader.PUT, headers, "key=value")