<?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>Abdul Qabiz on Web Technologies, Flash Platform, RIA, India &#187; as3httpclient</title>
	<atom:link href="http://www.abdulqabiz.com/blog/archives/tag/as3httpclient/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.abdulqabiz.com/blog</link>
	<description>a developer and entrepreneur on web technologies, adobe flash platform (flex, flash, air), web, opensource, linux, free software, usability, startups, India...</description>
	<lastBuildDate>Thu, 29 Jul 2010 14:53:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='www.abdulqabiz.com' port='80' path='/blog/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Adobe Flash Player 9.0.115.0 onwards allows setting Authorization HTTP header</title>
		<link>http://www.abdulqabiz.com/blog/archives/2009/01/06/adobe-flash-player-901150-onwards-allows-setting-authorization-http-header/</link>
		<comments>http://www.abdulqabiz.com/blog/archives/2009/01/06/adobe-flash-player-901150-onwards-allows-setting-authorization-http-header/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 10:20:00 +0000</pubDate>
		<dc:creator>Abdul Qabiz</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[as3httpclient]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flashplayer]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[http]]></category>

		<guid isPermaLink="false">http://www.abdulqabiz.com/wordpress/?p=422</guid>
		<description><![CDATA[
			
				
			
		
There were some issues with some earlier version of players, where it was not possible to set Authorization http-header for HTTP/GET requests. I tried to hack a way to do it using Socket or custom http-client in actionscript.
I just happened to read one of the technotes at Adobe&#8217;s site, which says Authorization header is allowed [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.abdulqabiz.com%2Fblog%2Farchives%2F2009%2F01%2F06%2Fadobe-flash-player-901150-onwards-allows-setting-authorization-http-header%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.abdulqabiz.com%2Fblog%2Farchives%2F2009%2F01%2F06%2Fadobe-flash-player-901150-onwards-allows-setting-authorization-http-header%2F&amp;source=abdulqabiz&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>There were some issues with some earlier version of players, <a href="http://www.abdulqabiz.com/blog/archives/flash_and_actionscript/http_authentica.php">where it was not possible to set Authorization http-header for HTTP/GET requests</a>. I <a href="http://www.abdulqabiz.com/blog/archives/apollo/as3httpclient_projec.php">tried to hack a way</a> to do it using Socket or custom http-client in actionscript.</p>
<p>I just happened to read <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403184&#038;sliceId=2">one of the technotes at Adobe&#8217;s site</a>, which says Authorization header is allowed for Flash Player 9.0.115.0 onwards. If you are trying to send request to another domain (different from the one hosting the SWF), a crossdomain-policy file is required.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abdulqabiz.com/blog/archives/2009/01/06/adobe-flash-player-901150-onwards-allows-setting-authorization-http-header/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>HTTP Authentication for HTTP/GET requests using ActionScript 3</title>
		<link>http://www.abdulqabiz.com/blog/archives/2006/03/03/http-authentication-for-httpget-requests-using-actionscript-3/</link>
		<comments>http://www.abdulqabiz.com/blog/archives/2006/03/03/http-authentication-for-httpget-requests-using-actionscript-3/#comments</comments>
		<pubDate>Fri, 03 Mar 2006 14:18:35 +0000</pubDate>
		<dc:creator>Abdul Qabiz</dc:creator>
				<category><![CDATA[Flash and Actionscript]]></category>
		<category><![CDATA[Macromedia Flex]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[as3httpclient]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[bloglines]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[httpurlloader]]></category>
		<category><![CDATA[socket]]></category>

		<guid isPermaLink="false">http://www.abdulqabiz.com/wordpress/?p=169</guid>
		<description><![CDATA[
			
				
			
		
I am working on ActionScript3 API for Bloglines services, which requires HTTP Authentication for its two of the services. I was not able to set the header of a HTTP/GET request. Macromedia Flash Player allows you set the header only for POST requests. I discussed this issues with Ted Patrick and he told me how [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.abdulqabiz.com%2Fblog%2Farchives%2F2006%2F03%2F03%2Fhttp-authentication-for-httpget-requests-using-actionscript-3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.abdulqabiz.com%2Fblog%2Farchives%2F2006%2F03%2F03%2Fhttp-authentication-for-httpget-requests-using-actionscript-3%2F&amp;source=abdulqabiz&amp;style=compact" height="61" width="50" /><br />
			</a>
		</div>
<p>I am working on ActionScript3 API for <a href="http://www.bloglines.com">Bloglines</a> <a href="http://bloglines.com/services/">services</a>, which requires HTTP Authentication for its two of the services. I was not able to set the header of a HTTP/GET request. Macromedia Flash Player allows you set the header only for POST requests. I discussed this issues with <a href="http://www.powersdk.com/ted/">Ted Patrick</a> and he told me how I can us <a href="http://livedocs.macromedia.com/labs/1/flex/langref/flash/net/Socket.html">Socket</a> to achieve the desired and he was very kind to give a me code-snippet, which got me started. Thanks Ted.</p>
<p>Finally, I could implement a class(HTTPURLLoader) which allows me to:</p>
<ul>
<li>Add request-headers</li>
<li>Do HTTP Authentication for GET URLs</li>
<li>Handle HTTP status messages</li>
<li>Read the complete response header</li>
</ul>
<p>It basically connects to a HTTP server on port 80(hardcoded for now) and sends an HTTP/1.0 request so that server closes the connection immediately after response. I could use HTTP/1.1 to keep connection alive and do things. But then closing connection would require some more logic, either a timeout logic if there is no activity on socket then close the connection, or find the end delimiter of response and then close. So I chose the easiest approach <img src='http://www.abdulqabiz.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I am still working on it and there is a lot(bugs-fixing, optimization, code-commenting, removing hardcoded stuff etc) to be done. I just wanted to share whatever I have done so far. I think, idea is more important than the implementation.<br />
Anyways, I also implemented <a href="http://www.ietf.org/rfc/rfc3548.txt">Base64</a> in AS3 and also <a href="http://www.opml.org/spec">OPML </a>parser for Bloglines. I would soon upload the entire Bloglines AS3 API source.</p>
<p><a href="http://www.abdulqabiz.com/files/HTTPURLLoader.zip">Download the code:</a></p>
<p>Usage:-</p>
<pre><code>&lt;mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" creationComplete="onAppInit()"&gt;
&lt;mx:Script&gt;
import flash.net.URLRequest;
import flash.net.URLRequestHeader;
import com.abdulqabiz.net.HTTPURLLoader;
import com.abdulqabiz.crypto.Base64;
private var loader:HTTPURLLoader;
private var END_POINT:String = "http://rpc.bloglines.com/";
//you need to set your email/password required for Bloglines access.
private var email:String = "YOUR_EMAIL_FOR_BLOGLINES";
private var password:String = "YOUR_BLOGLINES_PASSWORD";
private function onAppInit()
{
loader = new HTTPURLLoader();
loader.addEventListener("complete", onComplete);
loader.addEventListener("httpStatus", onHTTPStatus);
loader.addEventListener("progress", onProgress);
//for simplicity,not handling following three events.
//loader.addEventListener("close", onClose);
//loader.addEventListener("ioError", onIOError);
//loader.addEventListener("securityError",onSecurityError);
}
private function onComplete(event:Event)
{
//headers stroed as name-value(hash map)
var rh:Object = HTTPURLLoader(event.target).responseHeaders;
var str:String = "";
for(var p:String in rh)    str+= p + ":" + rh[p] + "\n";
console.text+="Response Headers: \n" + str + "\n\n";
//data property holds the content
console.text+="Body Content:\n" + HTTPURLLoader(event.target).data + "\n\n";
}
private function onProgress(event:ProgressEvent)
{
//bytesTotal is not accurate, and its 0 if server doesn't send Content-Length header.
console.text+= "Event: progress:-\n" + "bytesLoaded: " + event.bytesLoaded + "\n\n";
}
private function onHTTPStatus(event:HTTPStatusEvent)
{
//if httpStatus is 401, 403, 404, 500, 501, socket is closed.
console.text+= "Event: httpStatus (" + event.status + ")\n\n";
}
private function loadURL()
{
var request:URLRequest = new URLRequest();
//call listsubs method of Bloglines
request.url = END_POINT + "listsubs";
var credentials:String = Base64.encode(email + ":" + password);
//create HTTP Auth request header
var authHeader:URLRequestHeader = new URLRequestHeader("Authorization","Basic " + credentials);
//add the header to request
request.requestHeaders.push(authHeader);
//make the request.
loader.load(request);
}
&lt;/mx:Script&gt;
&lt;mx:Button label="Load URL" click="loadURL()"/&gt;
&lt;mx:TextArea id="console" width="100%" height="100%"/&gt;
&lt;/mx:Application&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.abdulqabiz.com/blog/archives/2006/03/03/http-authentication-for-httpget-requests-using-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
	</channel>
</rss>
