window.runtime property | window.runtime.flash.net.URLRequest |
Inheritance | URLRequest Object |
Runtime Versions: | AIR 1.0, |
load()
methods of the Loader, URLStream,
and URLLoader classes, and to other loading operations, to initiate URL downloads.
They are also passed to the upload()
and download()
methods
of the FileReference class.
By default, the calling file and the URL you load must be in the same domain. For example, a file at www.adobe.com can load data only from sources that are also at www.adobe.com.
However, in Adobe AIR, content in the application security sandbox (content installed with the AIR application) is not restricted by these security limitations. For content running in Adobe AIR, files in the application security sandbox can access URLs using any of the following URL schemes:
Files in the application security domain — files installed with the AIR application — can access URLs using any of the following URL schemes:
-
http
andhttps
-
file
-
app-storage
-
app
In AIR 3 or later, AIR applications can launch other applications using an arbitrary URI scheme
and the navigateToURL()
function. Prior to AIR 3, applications can only use the
standard URI schemes.
Content that is not in the application security sandbox observes the same restrictions as content running in the browser , and loading is governed by the content's domain.
For more information related to security, see the Flash Player Developer Center Topic: Security.
See also
Property | Defined By | ||
---|---|---|---|
authenticate : Boolean
Specifies whether authentication requests should be handled (true
or not (false) for this request. | URLRequest | ||
cacheResponse : Boolean
Specifies whether successful response data should be cached for this request. | URLRequest | ||
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
contentType : String
The MIME content type of the content in the the data property. | URLRequest | ||
data : Object
An object containing data to be transmitted with the URL request. | URLRequest | ||
digest : String
A string that uniquely identifies the signed Adobe platform component to be stored
to (or retrieved from) the Flash Player cache. | URLRequest | ||
followRedirects : Boolean
Specifies whether redirects are to be followed (true)
or not (false). | URLRequest | ||
idleTimeout : Number
Specifies the idle timeout value (in milliseconds) for this request. | URLRequest | ||
manageCookies : Boolean
Specifies whether the HTTP protocol stack should manage cookies for this
request. | URLRequest | ||
method : String
Controls the HTTP form submission method. | URLRequest | ||
prototype : Object [static]
A reference to the prototype object of a class or function object. | Object | ||
requestHeaders : Array
The array of HTTP request headers to be appended to the
HTTP request. | URLRequest | ||
url : String
The URL to be requested. | URLRequest | ||
useCache : Boolean
Specifies whether the local cache should be consulted before this URLRequest
fetches data. | URLRequest | ||
userAgent : String
Specifies the user-agent string to be used in the HTTP request. | URLRequest |
Method | Defined By | ||
---|---|---|---|
URLRequest(url:String = null)
Creates a URLRequest object. | URLRequest | ||
hasOwnProperty(name:String):Boolean
Indicates whether an object has a specified property defined. | Object | ||
isPrototypeOf(theClass:Object):Boolean
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
propertyIsEnumerable(name:String):Boolean
Indicates whether the specified property exists and is enumerable. | Object | ||
setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void
Sets the availability of a dynamic property for loop operations. | Object | ||
toLocaleString():String
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
toString():String
Returns the string representation of the specified object. | Object | ||
valueOf():Object
Returns the primitive value of the specified object. | Object |
authenticate | property |
authenticate:Boolean
Runtime Versions: | 1.0 |
Specifies whether authentication requests should be handled (true
or not (false
) for this request. If false
, authentication
challenges return an HTTP error.
The supported authentication methods are:
- Windows—HTTP Basic/Digest, Windows Integrated Authentication (including NTLM and Kerberos), SSL Certificate Authentication.
- Mac—HTTP Basic/Digest, NTLM, SSL Certificate Authentication.
Note:The FileReference.upload()
,
FileReference.download()
, and HTMLLoader.load()
methods do not support the URLRequest.authenticate
property.
The default value is true.
Throws
SecurityError — The caller is not in the AIR application security sandbox.
|
See also
cacheResponse | property |
cacheResponse:Boolean
Runtime Versions: | 1.0 |
Specifies whether successful response data should be cached for this request.
When set to true
, the AIR application uses the operating system's
HTTP cache.
Note:The HTMLLoader.load()
method
does not support the URLRequest.cacheResponse
property.
The default value is true.
Throws
SecurityError — The caller is not in the AIR application security sandbox.
|
See also
contentType | property |
contentType:String
Runtime Versions: | AIR 1.0, |
The MIME content type of the content in the the data
property.
The default value is application/x-www-form-urlencoded
.
Note:The FileReference.upload()
,
FileReference.download()
, and HTMLLoader.load()
methods do not
support the URLRequest.contentType
property.
When sending a POST request, the values of the contentType
and data
properties must correspond properly. The value of the contentType
property instructs servers on how to interpret the value of the data
property.
- If the value of the
data
property is a URLVariables object, the value ofcontentType
must beapplication/x-www-form-urlencoded
. - If the value of the
data
property is any other type, the value ofcontentType
should indicate the type of the POST data that will be sent (which is the binary or string data contained in the value of thedata
property). - For
FileReference.upload()
, the Content-Type of the request is set automatically tomultipart/form-data
, and the value of thecontentType
property is ignored.
In Flash Player 10 and later, if you use a multipart Content-Type (for example "multipart/form-data") that contains an upload (indicated by a "filename" parameter in a "content-disposition" header within the POST body), the POST operation is subject to the security rules applied to uploads:
- The POST operation must be performed in response to a user-initiated action, such as a mouse click or key press.
- If the POST operation is cross-domain (the POST target is not on the same server as the SWF file that is sending the POST request), the target server must provide a URL policy file that permits cross-domain access.
Also, for any multipart Content-Type, the syntax must be valid (according to the RFC2046 standards). If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads.
See also
data | property |
data:Object
Runtime Versions: | AIR 1.0, |
An object containing data to be transmitted with the URL request.
This property is used in conjunction with the method
property.
When the value of method
is GET
,
the value of data
is appended to the value of URLRequest.url
,
using HTTP query-string syntax. When the method
value is POST
(or any value other than GET
), the value
of data
is transmitted in the body of the HTTP request.
The URLRequest API offers binary POST
support and support for URL-encoded variables,
as well as support for strings. The data object can be a ByteArray, URLVariables,
or String object.
The way in which the data is used depends on the type of object used:
- If the object is a ByteArray object, the binary
data of the ByteArray object is used as
POST
data. ForGET
, data of ByteArray type is not supported. Also, data of ByteArray type is not supported forFileReference.upload()
andFileReference.download()
. - If the object is a URLVariables object and the method is
POST
, the variables are encoded using x-www-form-urlencoded format and the resulting string is used asPOST
data. An exception is a call toFileReference.upload()
, in which the variables are sent as separate fields in amultipart/form-data
post. - If the object is a URLVariables object and the method is
GET
, the URLVariables object defines variables to be sent with the URLRequest object. - Otherwise, the object is converted to a string, and the string
is used as the
POST
orGET
data.
This data is not sent until a method, such as navigateToURL()
or FileReference.upload()
, uses the URLRequest object.
Note: The value of contentType
must correspond to the type of data
in the data
property. See the note in the description of the
contentType
property.
See also
digest | property |
digest:String
Runtime Versions: | AIR 1.0, |
A string that uniquely identifies the signed Adobe platform component to be stored to (or retrieved from) the Flash Player cache. This property applies to SWF content only; it does not apply to JavaScript code running in AIR.
Throws
ArgumentError — The digest provided does not match the digest of the file that is
extracted from the downloaded signed file or the signed file loaded out of the cache. The
application also throws this error if the provided digest is the wrong length or contains invalid
(nonhexadecimal) characters.
|
followRedirects | property |
followRedirects:Boolean
Runtime Versions: | 1.0 |
Specifies whether redirects are to be followed (true
)
or not (false
).
Note:The FileReference.upload()
,
FileReference.download()
, and HTMLLoader.load()
methods do not
support the URLRequest.followRedirects
property.
The default value is true.
Throws
SecurityError — The caller is not in the AIR application security sandbox.
|
See also
idleTimeout | property |
idleTimeout:Number
Runtime Versions: | 2 |
Specifies the idle timeout value (in milliseconds) for this request.
The idle timeout is the amount of time the client waits for a response from the server, after the connection is established, before abandoning the request.
Note: The HTMLLoader.load()
method
does not support the URLRequest.idleTimeout
property.
The HTMLLoader class defines its own idleTimeout
property.
The default value is initialized from the URLRequestDefaults.idleTimeout property.
Throws
SecurityError — The caller is not in the AIR application security sandbox.
|
See also
manageCookies | property |
manageCookies:Boolean
Runtime Versions: | 1.0 |
Specifies whether the HTTP protocol stack should manage cookies for this
request. When true
, cookies are added to the request
and response cookies are remembered. If false
, cookies are
not added to the request and response cookies are not
remembered, but users can manage cookies themselves by direct header
manipulation.
Note: On Windows, you cannot add cookies to a URL request manually
when manageCookies
is set to true
. On other operating systems,
adding cookies to a request is permitted irrespective of whether manageCookies
is set to true
or false
. When permitted, you can add cookies
to a request manually by adding a URLRequestHeader
object containing the
cookie data to the requestHeaders
array.
On Mac OS, cookies are shared with Safari. To clear cookies on Mac OS:
- Open Safari.
- Select Safari > Preferences, and click the Security panel.
- Click the Show Cookies button.
- Click the Reomove All button.
To clear cookies on Windows:
- Open the Internet Properties control panel, and click the General tab.
- Click the Delete Cookies button.
The default value is true.
Throws
SecurityError — The caller is not in the AIR application security sandbox.
|
See also
method | property |
method:String
Runtime Versions: | AIR 1.0, |
Controls the HTTP form submission method.
You can use any string value
if the content is in the application security sandbox. Otherwise,
you are restricted to using GET or POST operations, and valid values are
URLRequestMethod.GET
or URLRequestMethod.POST
.
When
using the navigateToURL()
function, the runtime treats a URLRequest that uses the POST
method (one that has its method
property set to URLRequestMethod.POST
)
as using the GET method.
The default value is URLRequestMethod.GET.
Throws
ArgumentError — If the value parameter is not
URLRequestMethod.GET or URLRequestMethod.POST .
|
See also
Example ( How to use this example )
URLRequest.method
property to
URLRequestMethod.POST
.
Highlights of the example follow:
- The constructor function creates a URLRequest
instance named
request
, taking the URL of the remote application as a parameter. - A URLVariables object is created and two of its properties are assigned values.
- The URLVariables object is assigned to the
data
property of the URLRequest object. - The value of the
URLRequest.method
property is set toURLRequestMethod.POST
. - The example calls
navigateToURL
, which opens a new browser window to the remote application's URL.
Note: To run the example, the remote application URL in the example must be replaced with a working URL. Additionally, you would need server code to process the information captured by the AIR application in the URLVariables object.
<html> <head> <script src="AIRAliases.js" /> <script> function init() { var url = "http://www.[yourDomain].com/application.jsp"; var request = new air.URLRequest(url); var variables = new air.URLVariables(); variables.exampleSessionId = new Date().getTime(); variables.exampleUserLabel = "guest"; request.data = variables; request.method = air.URLRequestMethod.POST; air.navigateToURL(request); } </script> </head> <body onload='init()'> </body> </html>
requestHeaders | property |
requestHeaders:Array
Runtime Versions: | AIR 1.0, |
The array of HTTP request headers to be appended to the HTTP request. The array is composed of URLRequestHeader objects. Each object in the array must be a URLRequestHeader object that contains a name string and a value string, as follows:
var rhArray:Array = new Array(new URLRequestHeader("Content-Type", "text/html"));
The AIR runtime imposes certain restrictions on request headers; for more information, see the URLRequestHeader class description.
Not all methods that accept URLRequest parameters support the requestHeaders
property,
consult the documentation for the method you are calling. For example, the FileReference.upload()
and FileReference.download()
methods do not
support the URLRequest.requestHeaders
property.
Due to browser limitations, custom HTTP request headers are only supported for POST
requests,
not for GET
requests.
See also
url | property |
url:String
Runtime Versions: | AIR 1.0, |
The URL to be requested.
Be sure to encode any characters that are either described as unsafe in the Uniform Resource Locator
specification (see http://www.faqs.org/rfcs/rfc1738.html) or that are reserved in the
URL scheme of the URLRequest object (when not used for their reserved purpose). For example,
use "%25"
for the percent (%) symbol and "%23"
for the number sign (#), as in
"http://www.example.com/orderForm.cfm?item=%23B-3&discount=50%25"
.
By default, the URL must be in the same domain as the calling file, unless the content is running in the application security sandbox. . For more information, see the description of the URLRequest class.
Files in the application security sandobx — files installed with the AIR application — can access URLs using any of the following URL schemes:
http
andhttps
file
app-storage
app
Note: In AIR 3 and later, AIR applications can launch other applications that are registered
to handle an arbitrary URI scheme with the navigateToURL()
function. Prior to AIR 3,
only the standard URI schemes could be used. For example, you can use the http: scheme to launch the
default web browser and mailto: to launch the default email application.
Note: IPv6 (Internet Protocol version 6) is supported. IPv6 is a version of Internet Protocol that supports 128-bit addresses (an improvement on the earlier IPv4 protocol that supports 32-bit addresses). You might need to activate IPv6 on your networking interfaces. For more information, see the Help for the operating system hosting the data. If IPv6 is supported on the hosting system, you can specify numeric IPv6 literal addresses in URLs enclosed in brackets ([]).
See also
useCache | property |
useCache:Boolean
Runtime Versions: | 1.0 |
Specifies whether the local cache should be consulted before this URLRequest fetches data.
Note:The HTMLLoader.load()
method
does not support the URLRequest.useCache
property.
The default value is true.
Throws
SecurityError — The caller is not in the AIR application security sandbox.
|
See also
userAgent | property |
userAgent:String
Runtime Versions: | 1.0 |
Specifies the user-agent string to be used in the HTTP request.
Note: This property does not affect the user agent string when
the URLRequest object is used with the load()
method of an
HTMLLoader object. To set the user agent string for an HTMLLoader object,
set the userAgent
property of the HTMLLoader object or set
the static URLRequestDefaults.userAgent
property.
Throws
SecurityError — The caller is not in the AIR application security sandbox.
|
See also
URLRequest | () | Constructor |
public function URLRequest(url:String = null)
Runtime Versions: | AIR 1.0, |
Creates a URLRequest object.
If System.useCodePage
is true
, the request is encoded using the
system code page, rather than Unicode.
If System.useCodePage
is false
, the request is encoded using Unicode, rather than the
system code page.
url:String (default = null ) — The URL to be requested. You can set the URL later by using the url property.
|
See also
complete
event is dispatched and the data in the XML
file traces to the output. Additional event handlers capture other events, including error
events.
To run this example, place the AIRAliases.js file and an XML file named XMLFile.xml in the same directory as the HTML file.
<html> <head> <script src="AIRAliases.js" /> <script> function init() { var loader = new air.URLLoader(); configureListeners(loader); var request = new air.URLRequest("XMLFile.xml"); try { loader.load(request); } catch (error) { air.trace("Unable to load requested document."); } } function configureListeners(dispatcher) { dispatcher.addEventListener(air.Event.COMPLETE, completeHandler); dispatcher.addEventListener(air.Event.OPEN, openHandler); dispatcher.addEventListener(air.ProgressEvent.PROGRESS, progressHandler); dispatcher.addEventListener(air.SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); dispatcher.addEventListener(air.HTTPStatusEvent.HTTP_STATUS, httpStatusHandler); dispatcher.addEventListener(air.IOErrorEvent.IO_ERROR, ioErrorHandler); } function completeHandler(event) { var loader = air.URLLoader(event.target); air.trace("completeHandler: " + loader.data); } function openHandler(event) { air.trace("openHandler: " + event); } function progressHandler(event) { air.trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal); } function securityErrorHandler(event) { air.trace("securityErrorHandler: " + event); } function httpStatusHandler(event) { air.trace("httpStatusHandler: " + event); } function ioErrorHandler(event) { air.trace("ioErrorHandler: " + event); } </script> </head> <body onload='init()'> </body> </html>
Thu Sep 29 2011, 02:34 AM -07:00