On Mar 27, 2015 9:01 PM, "kevin.godell" <kevin.god...@gmail.com> wrote: > > I duplicated your situation with basic authentication and had the same > trouble of not being able to include the Authentication header using > urlstream. > Using Socket will allow you to authenticate and access the protected file, > but is a bit trickier.
Yes, I think this is best approach. And is essentially what the as3httpclient lib lets us do. Thanks, Om > > private var socket:Socket; > > private function connectSocket():void > { > if (!socket) > socket = new Socket; > socket.addEventListener(Event.CONNECT, > socket_connectHandler);//socket successfully connected > socket.addEventListener(IOErrorEvent.IO_ERROR, > socket_IOErrorHandler);//socket failed to connect > socket.addEventListener(ProgressEvent.SOCKET_DATA, > socket_dataHandler);//received data from socket > socket.addEventListener(Event.CLOSE, onSocketClose);//socket closed by > server > } > socket.connect("website.com", 80); > } > > private function socket_connectHandler(event:Event):void > { > var b64:Base64Encoder = new Base64Encoder; > b64.encode("user1:user1Password"); > var httpRequest:String = "GET /protected/testfile.txt > HTTP/1.1\r\n";//might try 1.0 depending on situation > httpRequest += "Authorization: Basic " + b64.toString() + "\r\n\r\n"; > socket.writeUTFBytes(httpRequest); > sock.flush(); > } > > private function socket_dataHandler(event:ProgressEvent):void > { > //the tricky part, figuring out what to do with the raw data > trace(socket.readUTFBytes(event.bytesLoaded)); > } > > > > > > > ----- > . > -- > View this message in context: http://apache-flex-users.2333346.n4.nabble.com/HTTP-Basic-Authentication-for-URLRequest-tp9803p9927.html > Sent from the Apache Flex Users mailing list archive at Nabble.com.