title: URLRequest in AS3 can't read the correct content when server return 403
body: <p>I'm using URLRequest in a Flash client to get some information from a service, the service will check the parameter in the request url, if the parameter is invalid, the server may return 403 with some content in http body, and I need analyse the content, the content is a json string:</p>
  
  <pre><code>{"code":3, "msg":"invalid channel"}
  </code></pre>
  
  <p>Unfortunately, sometimes the URLRequest can't read the content from URLStream, stream.bytesAvailable is 0, seems that the URLStream read null data.
  Is there any bug in URLRequest? Or it just because I'm using it in the wrong way?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>    public function test() {
          stream = new URLStream();
          request = new URLRequest(url);
          configureListeners(stream);
          var timer:Timer = new Timer(2000, 10);
          timer.addEventListener(TimerEvent.TIMER, onTimer);
          timer.start();
      }
  
      private function onTimer(e:TimerEvent):void {
          request.url = url + "&amp;timestamp=" + getTimer();
          trace("try to load: " + request.url);
          stream.load(request);
      }
  
      private function configureListeners(dispatcher:EventDispatcher):void {
          dispatcher.addEventListener(Event.COMPLETE, completeHandler);
          dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
          dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
      }
  
      private function completeHandler(event:Event):void {
          trace("completeHandler: " + event);
          parseHeader();
      }
  
      private function httpStatusHandler(event:HTTPStatusEvent):void {
          trace("httpStatusHandler: " + event);
      }
  
      private function ioErrorHandler(event:IOErrorEvent):void {
          trace("ioErrorHandler: " + event.toString());
          trace(stream.bytesAvailable + ", " + event.target.bytesAvailable + ", " + event.target.length);
      }
  </code></pre>
  
  <p>Here's the log:
  <a href="https://i.stack.imgur.com/vgtAD.png" rel="nofollow noreferrer">enter image description here</a></p>