GetResponseStream() public method

public GetResponseStream ( ) : Stream
return Stream
        /// <summary>
        /// Gets the response string from web exception.
        /// </summary>
        /// <param name="webException">
        /// The web exception.
        /// </param>
        /// <returns>
        /// Response string.
        /// </returns>
        internal static string GetResponseString(WebExceptionWrapper webException)
        {
            if (webException.HasResponse)
            {
                using (var stream = webException.GetResponseStream())
                {
                    if (stream != null)
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            return(reader.ReadToEnd());
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        internal static FacebookApiException GetGraphException(WebExceptionWrapper exception)
        {
            Contract.Requires(exception != null);

            FacebookApiException resultException = null;

            try
            {
                if (exception.HasResponse)
                {
                    object response = null;
                    string json     = null;
                    using (var stream = exception.GetResponseStream())
                    {
                        if (stream != null)
                        {
                            using (var reader = new StreamReader(stream))
                            {
                                json = reader.ReadToEnd();
                            }
                        }
                    }

                    if (json != null)
                    {
                        response = JsonSerializer.Current.DeserializeObject(json);
                    }

                    resultException = GetGraphException(response);
                }
            }
            catch
            {
                resultException = null;

                // We dont want to throw anything associated with
                // trying to build the FacebookApiException
            }

            return(resultException);
        }
Ejemplo n.º 3
0
        internal static FacebookApiException GetGraphException(WebExceptionWrapper exception)
        {
            Contract.Requires(exception != null);

            FacebookApiException resultException = null;
            try
            {
                if (exception.HasResponse)
                {
                    object response = null;
                    string json = null;
                    using (var stream = exception.GetResponseStream())
                    {
                        if (stream != null)
                        {
                            using (var reader = new StreamReader(stream))
                            {
                                json = reader.ReadToEnd();
                            }
                        }
                    }

                    if (json != null)
                    {
                        response = JsonSerializer.Current.DeserializeObject(json);
                    }

                    resultException = GetGraphException(response);
                }
            }
            catch
            {
                resultException = null;

                // We dont want to throw anything associated with 
                // trying to build the FacebookApiException
            }

            return resultException;
        }