<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gorbster.net &#187; actionscript 3</title>
	<atom:link href="http://www.gorbster.net/blog/archives/category/actionscript-3/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gorbster.net/blog</link>
	<description>gorbster at gmail dot com</description>
	<lastBuildDate>Thu, 29 Sep 2011 03:56:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Modifying request headers in ActionScript 3.0</title>
		<link>http://www.gorbster.net/blog/archives/9</link>
		<comments>http://www.gorbster.net/blog/archives/9#comments</comments>
		<pubDate>Fri, 14 Dec 2007 17:45:15 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://www.gorbster.net/blog/2007/12/14/modifying-request-headers-in-actionscript-30/</guid>
		<description><![CDATA[Though Adobe&#8217;s documentation would have you think otherwise, setting or modifying the request headers in an AS3, browser-based Flash application is only possible under certain circumstances. I&#8217;m testing this with player version 9,0,115,0 in both Safari 3 and Firefox 2 for OS X. The documented way to set request headers on an URLRequest object is [...]]]></description>
			<content:encoded><![CDATA[<p>Though <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/">Adobe&#8217;s documentation </a>would have you think otherwise, setting or modifying the request headers in an AS3, browser-based Flash application  is only possible under certain circumstances.  I&#8217;m testing this with player version 9,0,115,0 in both Safari 3 and Firefox 2 for OS X.</p>
<p>The documented way to set request headers on an URLRequest object is the following:</p>
<pre>
<code>var header:URLRequestHeader = new URLRequestHeader("myHeader", "headerValue");
var request:URLRequest = new URLRequest("http://www.[yourdomain].com/");
request.data = new URLVariables("name=John+Doe");
request.requestHeaders.push(header);</code></pre>
<p>However,  it seems like you can only modify the headers on a POST request. Which would mean we&#8217;d have to specify the POST method (assuming the remote site accepted POST requests for the URL):</p>
<pre>
<code>request.method = URLRequestMethod.POST;</code></pre>
<p>But even this isn&#8217;t sufficient, because the Flash Player will silently convert POST requests into GET requests if the request is empty. So now you have to add URLVariables to the mix:</p>
<pre>
<code>var variables:URLVariables = new URLVariables();
variables.postVariable = "variableValue";
request.data = variables;</code></pre>
<p>So the only way to successfully set or modify request headers on a URLRequest object is to set its method to POST, and make sure you send at least one variable along with the request. Otherwise the headers will silently remain unchanged.</p>
<p>This is unfortunate as it makes it difficult to connect a browser-based Flash application to a truly REST-ful Web service which determines the markup of content based on request headers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gorbster.net/blog/archives/9/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

