internal dynamic GetObjectResponse(IInternetServiceListener Listener = null)
        {
            IHttpWebResponse response = GetResponse(Listener);
            if (response == null)
                return null;

            HttpStatusCode sc = response.StatusCode;

            if (sc != HttpStatusCode.OK)
            {
                if (Listener != null)
                    Listener.OnStatusCodeKO(sc);

                return null;
            }

            Stream readStream = response.GetResponseStream();
            if (readStream == null)
            {
                if (Listener != null)
                    Listener.OnUnExpectedUnreadableResult();

                return null;
            }

            Stream toberead = null;

            if (response.ContentEncoding == "gzip")
            {
                toberead = new MemoryStream();

                using (Stream unzip = new System.IO.Compression.GZipStream(readStream, System.IO.Compression.CompressionMode.Decompress))
                {
                    unzip.CopyTo(toberead); 
                }

                toberead.Position = 0;
                readStream.Dispose();
            }
            else
                toberead = readStream;


            string sr = null;
            using (toberead)
            {
                using (StreamReader reader = new StreamReader(toberead))
                {
                    sr = reader.ReadToEnd();
                }

            }

            return DynamicJsonConverter.DynamicDeSerialize(sr);
        }
        ///// <summary>
        ///// Retrieve all Freedb servers from the main server site
        ///// </summary>
        ///// <param name="sites">SiteCollection that is populated with the site information</param>
        ///// <returns>Response Code</returns>
        //public List<Site> GetSites()
        //{
        //    return GetSites(Site.PROTOCOLS.ALL);
        //}

        #endregion


        ///// <summary>
        ///// Get the Freedb sites
        ///// </summary>
        ///// <param name="protocol"></param>
        ///// <param name="sites">SiteCollection that is populated with the site information</param>
        ///// <returns>Response Code</returns>
        ///// 
        //public List<Site> GetSites(string protocol )
        //{
        //    if (protocol != Site.PROTOCOLS.CDDBP  && protocol != Site.PROTOCOLS.HTTP)
        //        protocol = Site.PROTOCOLS.ALL;

        //    List<string> coll;

        //    try
        //    {
        //        coll= Call(Commands.CMD_SITES,m_mainSite.GetUrl());
        //    }

        //    catch (Exception ex)
        //    {
        //        Debug.WriteLine("Error retrieving Sites." + ex.Message);
        //        throw new Exception("FreedbHelper.GetSites: Error retrieving Sites.", ex);
        //    }


        //    // check if results came back
        //    if (coll.Count < 0)
        //    {
        //        string msg = "No results returned from sites request.";
        //        throw new Exception(msg,null);
        //    }

        //    string code = GetCode(coll[0]);
        //    if (code == ResponseCodes.CODE_INVALID)
        //    {
        //        string msg = "Unable to process results Sites Request. Returned Data: " + coll[0];
        //        throw new Exception(msg,null);

        //    }

        //    switch (code)
        //    {
        //        case ResponseCodes.CODE_500:
        //        case ResponseCodes.CODE_401:
        //            return null;

        //        case ResponseCodes.CODE_210:
        //        {
        //            coll.RemoveAt(0);
        //            List<Site> sites = new List<Site>();
        //            foreach (String line in coll)
        //            {
        //                Debug.WriteLine("line: " + line);
        //                Site site = new Site(line);
        //                if (protocol == Site.PROTOCOLS.ALL)
        //                    sites.Add(new Site(line));
        //                else if (site.Protocol == protocol)
        //                    sites.Add(new Site(line));
        //            }

        //            return sites;
        //        }

        //        default: 
        //            return null;
        //    }

        //}


        /// <summary>
        /// Read Entry from the database. 
        /// </summary>
        /// <param name="qr">A QueryResult object that is created by performing a query</param>
        /// <param name="cdEntry">out parameter - CDEntry object</param>
        /// <returns></returns>
        //public CDEntry Read(QueryResult qr)
        //{
        //    Debug.Assert(qr != null);

        //    List<string> coll = null;
        //    StringBuilder builder = new StringBuilder(FreedbHelper.Commands.CMD_READ);
        //    builder.Append("+");
        //    builder.Append(qr.Category);
        //    builder.Append("+");
        //    builder.Append(qr.Discid);

        //    //make call
        //    try
        //    {
        //        coll = Call(builder.ToString());
        //    }

        //    catch (Exception ex)
        //    {
        //        string msg = "Error performing cddb read.";
        //        throw new Exception(msg,ex);
        //    }

        //    // check if results came back
        //    if (coll.Count < 0)
        //    {
        //        string msg = "No results returned from cddb read.";
        //        throw new Exception(msg,null);
        //    }


        //    string code = GetCode(coll[0]);
        //    if (code == ResponseCodes.CODE_INVALID)
        //    {
        //        string msg = "Unable to process results for cddb read. Returned Data: " + coll[0];
        //        throw new Exception(msg,null);
        //    }


        //    switch (code)
        //    {
        //        case ResponseCodes.CODE_500: // query problem
        //        case ResponseCodes.CODE_401: // entry not found
        //        case ResponseCodes.CODE_402: // server error
        //        case ResponseCodes.CODE_403: // Database entry is corrupt
        //        case ResponseCodes.CODE_409: // No handshake
        //            return null;

        //        case ResponseCodes.CODE_210: // good 
        //        {
        //            coll.RemoveAt(0); // remove the 210
        //            return new CDEntry(coll);
        //        }
        //        default:
        //            return null;
        //    }
        //}

        /// <summary>
        /// Read Entry from the database. 
        /// </summary>
        /// <param name="qr">A QueryResult object that is created by performing a query</param>
        /// <param name="cdEntry">out parameter - CDEntry object</param>
        /// <returns></returns>
        internal AlbumDescriptor ConvertToAlbumDescriptor(QueryResult qr, IInternetServiceListener listener)
        {
            Debug.Assert(qr != null);

            List<string> coll = null;
            StringBuilder builder = new StringBuilder(FreedbHelper.Commands.CMD_READ);
            builder.Append("+");
            builder.Append(qr.Category);
            builder.Append("+");
            builder.Append(qr.Discid);

            //make call
            try
            {
                coll = Call(builder.ToString());
            }

            catch (WebException ex)
            {
                if (listener != null)
                    listener.OnWebExeption(ex);
                return null;
            }
            catch (Exception)
            {
                return null;
            }

            // check if results came back
            if (coll.Count == 0)
            {
                return null;
            }


            string code = GetCode(coll[0]);
            if (code == ResponseCodes.CODE_INVALID)
            {
                if (listener != null)
                    listener.OnUnExpectedUnreadableResult("Unable to process results for cddb read.");
                return null;
            }


            switch (code)
            {
                case ResponseCodes.CODE_500: // query problem
                case ResponseCodes.CODE_401: // entry not found
                case ResponseCodes.CODE_402: // server error
                case ResponseCodes.CODE_403: // Database entry is corrupt
                case ResponseCodes.CODE_409: // No handshake
                    return null;

                case ResponseCodes.CODE_210: // good 
                    {
                        coll.RemoveAt(0); // remove the 210
                        return AlbumDescriptor.FromFreeDBInfo(coll);
                    }
                default:
                    if (listener != null)
                        listener.OnStatusCodeKO();
                    return null;
            }
        }