# Metadata
Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 2.5 Security: network
# Syntax
https
# Examples
set the htmlText of field 1 to URL "https://example.org/data.html"
put URL "https://www.example.com/output?this=that" into testData
put line 2 of URL "https://www.example.com/stuff/" into testDate
# Description
The URL scheme "http" indicates information located on a web server. An http URL consists of:
1. The string "https://" 2. An optional user name and password, separated by a colon (:) and followed by "@" 3. The name of the server (for instance, "example.net") followed by a slash 4. The location of the resource (often, a file path).
Here are some examples of valid https URLs: * 'https://www.example.com' : The main page for the server "www.example.com" * 'https://www.example.com/directory/' : A directory on the server * 'https://www.example.com/directory/file.html' : A file on the server * 'https://user:password@www.example.com/file.txt' : A file accessed by a user name and password * 'https://www.example.com/directory/stuff.html?list=yes' : A page generated by a query - possibly generated by a CGI
>*Important:* If your user name or password contains any of the > characters ":", "@", "/", ".", or "|", use the URLEncode function to > safely encode the user name or password before putting them into the > URL. The following example constructs a URL for > a user whose password contains the "@" character:
put "name" into userName put "jdoe@example.com" into userPassword put "https://" & userName & ":" & URLEncode(userPassword) \ & "@www.example.net/index.html" into fileURLToGet get URL fileURLToGet
An http URL is a container, and you can use the expression URL httpURL in any statement where any other container type is used. When you get the value of an http URL, LiveCode downloads the URL from the server. (If you have previously cache the URL with the load command, it fetches the URL from the cache.)
>*Note:* Transferring a URL by using it in an expression is > a blocking operation: that is, the handler pauses until LiveCode > is finished getting the URL. Since contacting a server > may take some time due to network lag, URL operations may > take long enough to be noticeable to the user.
The following example shows how to set a flag in a global variable to prevent multiple downloads. The variable "gDownloadInProgress" is set to true while a download is going on, and back to false when the download concludes. If the user clicks the button again while the download is still going on, the handler simply beeps:
on mouseUp global gDownloadInProgress if gDownloadInProgress then beep exit mouseUp end if put true into gDownloadInProgress -- about to start put URL (field "Page to get") into field "Command Result" put false into gDownloadInProgress -- finished end mouseUp
For technical information about URLs and the https URL scheme, see [RFC 1630](https://tools.ietf.org/html/rfc1630).
>*Important:* The https keyword is part of the > Internet library on desktop platforms. To ensure that the keyword > works in a desktop standalone application, you must include this > LiveCode custom library when you create your > standalone application. In the Inclusions pane of the > Standalone Application Settings window, make sure the "Internet" > script library is selected.
>*Cross-platform note:* On iOS and Android, you can use the https > keyword without the need for the Internet library. When > specifying > URLs for iOS and Android, you must use the > appropriate > form that conforms to [RFC > 1630](https://tools.ietf.org/html/rfc1630).
# Tags
# See
- **message:** startup, openBackground, preOpenStack, openStack, preOpenCard - **library:** Internet library, library - **keyword:** URL, file, ftp, button, word, http - **control structure:** function - **function:** result, files, libURLErrorData, value - **command:** post, put, load, group, delete URL, get, libURLSetCustomHTTPHeaders - **glossary:** LiveCode custom library, application, standalone application, evaluate, server, blocking, cache, statement, URL, command, container, expression, main stack, keyword, Standalone Application Settings, upload, download, message, flag, handler