ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
URLRequestHeader

Package | flash.net
Class | public final class URLRequestHeader
Inheritance | URLRequestHeader Object

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

A URLRequestHeader object encapsulates a single HTTP request header and consists of a name/value pair. URLRequestHeader objects are used in the `requestHeaders` property of the URLRequest class.

The following request headers cannot be used, and the restricted terms are not case-sensitive (for example, `Get`, `get`, and `GET` are all not allowed). Also, hyphenated terms apply if an underscore character is used (for example, both `Content-Length` and `Content_Length` are not allowed):

`Accept-Charset`, `Accept-Encoding`, `Accept-Ranges`, `Age`, `Allow`, `Allowed`, `Authorization`, `Charge-To`, `Connect`, `Connection`, `Content-Length`, `Content-Location`, `Content-Range`, `Cookie`, `Date`, `Delete`, `ETag`, `Expect`, `Get`, `Head`, `Host`, `Keep-Alive`, `Last-Modified`, `Location`, `Max-Forwards`, `Options`, `Post`, `Proxy-Authenticate`, `Proxy-Authorization`, `Proxy-Connection`, `Public`, `Put`, `Range`, `Referer`, `Request-Range`, `Retry-After`, `Server`, `TE`, `Trace`, `Trailer`, `Transfer-Encoding`, `Upgrade`, `URI`, `User-Agent`, `Vary`, `Via`, `Warning`, `WWW-Authenticate`, `x-flash-version`.

URLRequestHeader objects are restricted in length. If the cumulative length of a URLRequestHeader object (the length of the `name` property plus the `value` property) or an array of URLRequestHeader objects used in the `URLRequest.requestHeaders` property exceeds the acceptable length, Adobe® Flash® Player throws an exception.

View the examples

See also

URLRequest
URLLoader

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | name : String An HTTP request header name (such as Content-Type or SOAPAction). | URLRequestHeader
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object
|  | value : String The value associated with the name property (such as text/plain). | URLRequestHeader

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | URLRequestHeader(name:String = "", value:String = "") Creates a new URLRequestHeader object that encapsulates a single HTTP request header. | URLRequestHeader
|  | 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
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

name | property

`public var name:String`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

An HTTP request header name (such as `Content-Type` or `SOAPAction`).

value | property |

`public var value:String`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

The value associated with the `name` property (such as `text/plain`).

Constructor Detail

URLRequestHeader | () | Constructor

`public function URLRequestHeader(name:String = "", value:String = "")`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Creates a new URLRequestHeader object that encapsulates a single HTTP request header. URLRequestHeader objects are used in the `requestHeaders` property of the URLRequest class.

Parameters

| `name:String` (default = "``")`` — An HTTP request header name (such as `Content-Type` or `SOAPAction`).
| `value:String` (default = "``")`` — The value associated with the `name` property (such as `text/plain`).

Examples How to use examples
URLRequestHeaderExample.as
The following example adds a single HTTP request header `header` to the array for the `requestHeaders` property. The header indicates that the application should forward the request to the origin server even if it has a cached copy of what is being requested.

    package {
        import flash.display.Sprite;
        import flash.events.*;
        import flash.net.URLLoader;
        import flash.net.URLRequest;
        import flash.net.URLRequestHeader;
        import flash.net.URLRequestMethod;
        import flash.net.URLVariables;

        public class URLRequestHeaderExample extends Sprite {
            public function URLRequestHeaderExample() {
                var loader:URLLoader = new URLLoader();
                configureListeners(loader);

                var header:URLRequestHeader = new URLRequestHeader("pragma", "no-cache");
                var request:URLRequest = new URLRequest("http://www.[yourdomain].com/greeting.cfm");
                request.data = new URLVariables("name=John+Doe");
                request.method = URLRequestMethod.POST;
                request.requestHeaders.push(header);
                try {
                    loader.load(request);
                } catch (error:Error) {
                    trace("Unable to load requested document.");
                }
            }

            private function configureListeners(dispatcher:IEventDispatcher):void {
                dispatcher.addEventListener(Event.COMPLETE, completeHandler);
                dispatcher.addEventListener(Event.OPEN, openHandler);
                dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
                dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
                dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            }

            private function completeHandler(event:Event):void {
                var loader:URLLoader = URLLoader(event.target);
                trace("completeHandler: " + loader.data);
            }

            private function openHandler(event:Event):void {
                trace("openHandler: " + event);
            }

            private function progressHandler(event:ProgressEvent):void {
                trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
            }

            private function securityErrorHandler(event:SecurityErrorEvent):void {
                trace("securityErrorHandler: " + event);
            }

            private function httpStatusHandler(event:HTTPStatusEvent):void {
                trace("httpStatusHandler: " + event);
            }

            private function ioErrorHandler(event:IOErrorEvent):void {
                trace("ioErrorHandler: " + event);
            }
        }
    }

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00