/// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="downloadedContent">the downloaded content</param>
 /// <param name="statusCode">Status code from the server</param>
 /// <param name="statusMessage">Status message from the server</param>
 /// <param name="responseHeaders">Headers in this response</param>
 public WebResponseData(DownloadedContent downloadedContent, int statusCode, String statusMessage,
                        List <NameValuePair> responseHeaders)
 {
     statusCode_        = statusCode;
     statusMessage_     = statusMessage;
     responseHeaders_   = Collections.unmodifiableList(responseHeaders);
     downloadedContent_ = downloadedContent;
 }
        private InputStream GetStream(DownloadedContent downloadedContent,
                                      List <NameValuePair> headers)
        {
            InputStream stream = downloadedContent_.InputStream;

            if (stream == null)
            {
                return(null);
            }

            if (downloadedContent.IsEmpty())
            {
                return(stream);
            }

            String encoding = GetHeader(headers, "content-encoding");

            if (encoding != null)
            {
                if (StringUtils.contains(encoding, "gzip"))
                {
                    stream = new GZIPInputStream(stream);
                }
                else if (StringUtils.contains(encoding, "deflate"))
                {
                    bool zlibHeader = false;
                    if (stream.MarkSupported)
                    { // should be always the case as the content is in a byte[] or in a file
                        stream.Mark(2);
                        byte[] buffer = new byte[2];
                        stream.Read(buffer, 0, 2);
                        zlibHeader = (((buffer[0] & 0xff) << 8) | (buffer[1] & 0xff)) == 0x789c;
                        stream.Reset();
                    }
                    if (zlibHeader)
                    {
                        stream = new InflaterInputStream(stream);
                    }
                    else
                    {
                        stream = new InflaterInputStream(stream, new Inflater(true));
                    }
                }
            }
            return(stream);
        }
        private InputStream GetStream(DownloadedContent downloadedContent,
                    List<NameValuePair> headers)
        {

            InputStream stream = downloadedContent_.InputStream;
            if (stream == null)
            {
                return null;
            }

            if (downloadedContent.IsEmpty())
            {
                return stream;
            }

            String encoding = GetHeader(headers, "content-encoding");
            if (encoding != null)
            {
                if (StringUtils.contains(encoding, "gzip"))
                {
                    stream = new GZIPInputStream(stream);
                }
                else if (StringUtils.contains(encoding, "deflate"))
                {
                    bool zlibHeader = false;
                    if (stream.MarkSupported)
                    { // should be always the case as the content is in a byte[] or in a file
                        stream.Mark(2);
                        byte[] buffer = new byte[2];
                        stream.Read(buffer, 0, 2);
                        zlibHeader = (((buffer[0] & 0xff) << 8) | (buffer[1] & 0xff)) == 0x789c;
                        stream.Reset();
                    }
                    if (zlibHeader)
                    {
                        stream = new InflaterInputStream(stream);
                    }
                    else
                    {
                        stream = new InflaterInputStream(stream, new Inflater(true));
                    }
                }
            }
            return stream;
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="downloadedContent">the downloaded content</param>
 /// <param name="statusCode">Status code from the server</param>
 /// <param name="statusMessage">Status message from the server</param>
 /// <param name="responseHeaders">Headers in this response</param>
 public WebResponseData(DownloadedContent downloadedContent, int statusCode, String statusMessage,
         List<NameValuePair> responseHeaders)
 {
     statusCode_ = statusCode;
     statusMessage_ = statusMessage;
     responseHeaders_ = Collections.unmodifiableList(responseHeaders);
     downloadedContent_ = downloadedContent;
 }