I believe the separation of the header from the body is the double CR. It's been a while since I've seen the standard.
-Mark -----Original Message----- From: Deepak MS [mailto:megharajdee...@gmail.com] Sent: Wednesday, April 01, 2015 2:11 AM To: users@flex.apache.org Subject: Re: HTTP Basic Authentication for URLRequest After all the experiments, this is what I have got. Om, as3httpclient isn't giving me a progress event(I need progress event to write the downloading file data in chunks). I thought onData event would give me progress, but it isn't. Is there any other event I can try? Kevin, Your solution worked well. It authenticated the URL file(zip file). I did not get username\password popup. It writes the file and creates it. But it isn't opening the zip file. When I looked at the file size, I could see 320bytes of data is more than original file size. I think that's why file is reported as corrupt and it is not opening. This is what I am doing under progress event to create the zip file(it just appends the data that we get in progress) private function socket_dataHandler(event:ProgressEvent):void { //the tricky part, figuring out what to do with the raw data // trace(socket.readUTFBytes(event.bytesLoaded)); localZipFile = File.desktopDirectory.resolvePath('C:\\Desktop\\dowloadedZipFile.zip'); var bytes:ByteArray = new ByteArray(); socket.readBytes(bytes,bytes.length); fileStream = new FileStream(); fileStream.addEventListener(Event.CLOSE, fileClosed); fileStream.addEventListener(IOErrorEvent.IO_ERROR, onFSIOError); fileStream.open( localZipFile, localZipFile.exists ? FileMode.APPEND:FileMode.WRITE); fileStream.writeBytes( bytes ); fileStream.close(); } After that, I tried to download and write a simple text file instead of zip file. The text file just has 'Hello' written in it. This time, file got downloaded and got written on the disk. But when I opened it, this is what I got: "HTTP/1.1 200 OK Cache-Control: max-age=31536000 Content-Type: text/plain Last-Modified: Wed, 01 Apr 2015 05:20:10 GMT Accept-Ranges: bytes ETag: "859b56863b6cd01:0" Server: Microsoft-IIS/7.0 X-Powered-By: ASP.NET Date: Wed, 01 Apr 2015 05:55:05 GMT Connection: close Content-Length: 5 Hello" And I feel this is the reason, zip is getting corrupted as it has some extra header details in it. So how can I avoid writing this header part to my zip file?