Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:08:24+00:00 2026-06-05T03:08:24+00:00

I get warning on responseStream in following function: private static string GetResponseString(WebResponse response) {

  • 0

I get warning on responseStream in following function:

private static string GetResponseString(WebResponse response)
        {
            using (var responseStream = response.GetResponseStream())
            {
                if (responseStream != null)
                {
                    using (var responseReader = new StreamReader(responseStream))
                    {
                        var strResponse = responseReader.ReadToEnd();
                        return strResponse;
                    }
                }
            }

            return string.Empty;
        }

I call this function from places like like this one:

var request = (HttpWebRequest)WebRequest.Create(Uri);
            request.Headers.Add("Authorization", "GoogleLogin auth=" + this.SecurityToken);
            request.ContentType = "application/x-www-form-urlencoded";
            request.Method = "POST";
            request.Timeout = 5000;

            // build the post string     
            var postString = new StringBuilder();
            postString.AppendFormat("registration_id={0}", recipientId);
            postString.AppendFormat("&data.payload={0}", message);
            postString.AppendFormat("&collapse_key={0}", collapseKey);

            // write the post-string as a byte array     
            var requestData = Encoding.ASCII.GetBytes(postString.ToString());
            request.ContentLength = requestData.Length;
            var requestStream = request.GetRequestStream();
            requestStream.Write(requestData, 0, requestData.Length);
            requestStream.Close();

            // Do the actual request and read the response stream  
            try
            {
                var response = request.GetResponse();
                var responseString = GetResponseString(response);
                response.Close();

                return responseString.Contains("id=") 
                    ? SendStatus.Ok 
                    : GetSendStatusFromResponse(responseString);
            }
            catch (WebException ex)
            {
                var webResponse = (HttpWebResponse)ex.Response;
                if (webResponse != null)
                {
                    if (webResponse.StatusCode.Equals(HttpStatusCode.Unauthorized))
                    {
                        return SendStatus.Unauthorized;
                    }

                    if (webResponse.StatusCode.Equals(HttpStatusCode.ServiceUnavailable))
                    {
                        return SendStatus.ServiceUnavailable;
                    }
                }

                this.LoggerService.Log(null, ex);
                return SendStatus.GeneralException;
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:08:27+00:00Added an answer on June 5, 2026 at 3:08 am

    StreamReader takes ownership of the stream passed to it in the constructor call in the sense that it will call Dispose on it when the StreamReader itself is closed – hence it will already be disposed when the outer Using statement attempts to dispose of it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using GWT I get following warning: Referencing deprecated class 'com.google.gwt.user.client.rpc.SerializableException' While it's only
I get this warning on response.GetResponseStream() How should I handle this? // Get response
I get following warning- warning: passing argument 1 of 'dismissWithClickedButtonIndex:animated:' makes integer from pointer
When building using Maven on my mac, on mvn install i get [WARNING] Using
I keep getting 'warning: control reaches end of non-void function' with this code: static
I get the warning message: file_get_contents failed to open stream permission denied I have
The exact warning I get is warning C4715: 'hand::show' : not all control paths
I get a warning in MSVC++ when I try to read an integer from
I get the warning warning, -s option given but default rule can be matched
I get this: Warning: session_start(): Cannot send session cookie - headers already sent by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.