1//////////////////////////////////////////////////////////////////////////////// 2// 3// ADOBE SYSTEMS INCORPORATED 4// Copyright 2005-2007 Adobe Systems Incorporated 5// All Rights Reserved. 6// 7// NOTICE: Adobe permits you to use, modify, and distribute this file 8// in accordance with the terms of the license agreement accompanying it. 9// 10//////////////////////////////////////////////////////////////////////////////// 11 12package mx.messaging.messages 13{ 14 15// import mx.resources.IResourceManager; 16// import mx.resources.ResourceManager; 17 18// [ResourceBundle("messaging")] 19 20[RemoteClass(alias="flex.messaging.messages.HTTPMessage")] 21 22/** 23 * HTTP requests are sent to the HTTP endpoint using this message type. 24 * An HTTPRequestMessage encapsulates content and header information normally 25 * found in HTTP requests made by a browser. 26 */ 27public class HTTPRequestMessage extends AbstractMessage 28{ 29 //-------------------------------------------------------------------------- 30 // 31 // Constructor 32 // 33 //-------------------------------------------------------------------------- 34 35 /** 36 * Constructs an uninitialized HTTP request. 37 */ 38 public function HTTPRequestMessage() 39 { 40 super(); 41 _method = GET_METHOD; 42 } 43 44 //-------------------------------------------------------------------------- 45 // 46 // Variables 47 // 48 //-------------------------------------------------------------------------- 49 50 /** 51 * Indicates the content type of this message. 52 * This value must be understood by the destination this request is sent to. 53 * 54 * <p>The following example sets the <code>contentType</code> property:</p> 55 * <pre> 56 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 57 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 58 * msg.method = HTTPRequestMessage.POST_METHOD; 59 * msg.url = "http://my.company.com/login"; 60 * </pre> 61 */ 62 public var contentType:String; 63 64 /** 65 * Contains specific HTTP headers that should be placed on the request made 66 * to the destination. 67 */ 68 public var httpHeaders:Object; 69 70 /** 71 * Only used when going through the proxy, should the proxy 72 * send back the request and response headers it used. Defaults to false. 73 * Currently only set when using the NetworkMonitor. 74 */ 75 public var recordHeaders:Boolean; 76 77 [Inspectable(defaultValue="undefined", category="General")] 78 /** 79 * Contains the final destination for this request. 80 * This is the URL that the content of this message, found in the 81 * <code>body</code> property, will be sent to, using the method specified. 82 * 83 * <p>The following example sets the <code>url</code> property:</p> 84 * <pre> 85 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 86 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 87 * msg.method = HTTPRequestMessage.POST_METHOD; 88 * msg.url = "http://my.company.com/login"; 89 * </pre> 90 */ 91 public var url:String; 92 93 /** 94 * @private 95 private var resourceManager:IResourceManager = 96 ResourceManager.getInstance(); 97 */ 98 99 //-------------------------------------------------------------------------- 100 // 101 // Properties 102 // 103 //-------------------------------------------------------------------------- 104 105 //---------------------------------- 106 // method 107 //---------------------------------- 108 109 /** 110 * @private 111 */ 112 private var _method:String; 113 114 [Inspectable(category="General")] 115 /** 116 * Indicates what method should be used for the request. 117 * The only values allowed are: 118 * <ul> 119 * <li><code>HTTPRequestMessage.DELETE_METHOD</code></li> 120 * <li><code>HTTPRequestMessage.GET_METHOD</code></li> 121 * <li><code>HTTPRequestMessage.HEAD_METHOD</code></li> 122 * <li><code>HTTPRequestMessage.POST_METHOD</code></li> 123 * <li><code>HTTPRequestMessage.OPTIONS_METHOD</code></li> 124 * <li><code>HTTPRequestMessage.PUT_METHOD</code></li> 125 * <li><code>HTTPRequestMessage.TRACE_METHOD</code></li> 126 * </ul> 127 * 128 * <p>The following example sets the <code>method</code> property:</p> 129 * <pre> 130 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 131 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 132 * msg.method = HTTPRequestMessage.POST_METHOD; 133 * msg.url = "http://my.company.com/login"; 134 * </pre> 135 */ 136 public function get method():String 137 { 138 return _method; 139 } 140 141 /** 142 * @private 143 */ 144 public function set method(value:String):void 145 { 146 /* 147 if (VALID_METHODS.indexOf(value) == -1) 148 { 149 var message:String = resourceManager.getString( 150 "messaging", "invalidRequestMethod"); 151 throw new ArgumentError(message); 152 } 153 */ 154 155 _method = value; 156 } 157 158 //-------------------------------------------------------------------------- 159 // 160 // Static Constants 161 // 162 //-------------------------------------------------------------------------- 163 164 /** 165 * Indicates that the content of this message is XML. 166 * 167 * <p>The following example uses this constant:</p> 168 * <pre> 169 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 170 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_XML; 171 * msg.method = HTTPRequestMessage.POST_METHOD; 172 * msg.url = "http://my.company.com/login"; 173 * </pre> 174 */ 175 public static const CONTENT_TYPE_XML:String = "application/xml"; 176 177 /** 178 * Indicates that the content of this message is a form. 179 * 180 * <p>The following example uses this constant:</p> 181 * <pre> 182 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 183 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 184 * msg.method = HTTPRequestMessage.POST_METHOD; 185 * msg.url = "http://my.company.com/login"; 186 * </pre> 187 */ 188 public static const CONTENT_TYPE_FORM:String = "application/x-www-form-urlencoded"; 189 190 /** 191 * Indicates that the content of this message is XML meant for a SOAP 192 * request. 193 * 194 * <p>The following example uses this constant:</p> 195 * <pre> 196 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 197 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_SOAP_XML; 198 * msg.method = HTTPRequestMessage.POST_METHOD; 199 * msg.url = "http://my.company.com/login"; 200 * </pre> 201 */ 202 public static const CONTENT_TYPE_SOAP_XML:String = "text/xml; charset=utf-8"; 203 204 /** 205 * Indicates that the method used for this request should be "post". 206 * 207 * <p>The following example uses this constant:</p> 208 * <pre> 209 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 210 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 211 * msg.method = HTTPRequestMessage.POST_METHOD; 212 * msg.url = "http://my.company.com/login"; 213 * </pre> 214 */ 215 public static const POST_METHOD:String = "POST"; 216 217 /** 218 * Indicates that the method used for this request should be "get". 219 * 220 * <p>The following example uses this constant:</p> 221 * <pre> 222 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 223 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 224 * msg.method = HTTPRequestMessage.GET_METHOD; 225 * msg.url = "http://my.company.com/login"; 226 * </pre> 227 */ 228 public static const GET_METHOD:String = "GET"; 229 230 /** 231 * Indicates that the method used for this request should be "put". 232 * 233 * <p>The following example uses this constant:</p> 234 * <pre> 235 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 236 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 237 * msg.method = HTTPRequestMessage.PUT_METHOD; 238 * msg.url = "http://my.company.com/login"; 239 * </pre> 240 */ 241 public static const PUT_METHOD:String = "PUT"; 242 243 /** 244 * Indicates that the method used for this request should be "head". 245 * 246 * <p>The following example uses this constant:</p> 247 * <pre> 248 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 249 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 250 * msg.method = HTTPRequestMessage.HEAD_METHOD; 251 * msg.url = "http://my.company.com/login"; 252 * </pre> 253 */ 254 public static const HEAD_METHOD:String = "HEAD"; 255 256 /** 257 * Indicates that the method used for this request should be "delete". 258 * 259 * <p>The following example uses this constant:</p> 260 * <pre> 261 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 262 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 263 * msg.method = HTTPRequestMessage.DELETE_METHOD; 264 * msg.url = "http://my.company.com/login"; 265 * </pre> 266 */ 267 public static const DELETE_METHOD:String = "DELETE"; 268 269 /** 270 * Indicates that the method used for this request should be "options". 271 * 272 * <p>The following example uses this constant:</p> 273 * <pre> 274 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 275 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 276 * msg.method = HTTPRequestMessage.OPTIONS_METHOD; 277 * msg.url = "http://my.company.com/login"; 278 * </pre> 279 */ 280 public static const OPTIONS_METHOD:String = "OPTIONS"; 281 282 /** 283 * Indicates that the method used for this request should be "trace". 284 * 285 * <p>The following example uses this constant:</p> 286 * <pre> 287 * var msg:HTTPRequestMessage = new HTTPRequestMessage(); 288 * msg.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM; 289 * msg.method = HTTPRequestMessage.TRACE_METHOD; 290 * msg.url = "http://my.company.com/login"; 291 * </pre> 292 */ 293 public static const TRACE_METHOD:String = "TRACE"; 294 295 /** 296 * @private 297 */ 298 private static const VALID_METHODS:String = "POST,PUT,GET,HEAD,DELETE,OPTIONS,TRACE"; 299} 300 301} 302