HttpWebResponse is truncated

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dean Rettig

    #1

    HttpWebResponse is truncated

    I am using HttpWebRequest to get an HttpWebResponse from an https://
    site.

    I am using cookies and certificates and everything seems to be working
    properly EXCEPT...

    The largest (html) document that I am trying to read is about 28788
    bytes when downloaded using Firefox

    but when my dotnet app tries to retrieve it, the response is only about
    26580 bytes. Here is a code snippet:

    HttpWebResponse response = (HttpWebRespons e) request.GetResp onse ( );
    System.Text.Enc oding enc = System.Text.Enc oding.GetEncodi ng(1252); //
    Windows default Code Page
    System.IO.Strea mReader reader = new System.IO.Strea mReader(
    response.GetRes ponseStream(), enc );
    string content = reader.ReadToEn d();
    reader.Close();
    response.Close( );

    I've tried different methods of StreamReader all with the same results.
    Can anyone tell me where the last 2KB of my response is going and how
    I can get it back?

    Muchas grathias,
    Dean

  • Jon Skeet [C# MVP]

    #2
    Re: HttpWebResponse is truncated

    Dean Rettig <rettigcd@gmail .comwrote:
    I am using HttpWebRequest to get an HttpWebResponse from an https://
    site.
    >
    I am using cookies and certificates and everything seems to be working
    properly EXCEPT...
    >
    The largest (html) document that I am trying to read is about 28788
    bytes when downloaded using Firefox
    >
    but when my dotnet app tries to retrieve it, the response is only about
    26580 bytes. Here is a code snippet:
    >
    HttpWebResponse response = (HttpWebRespons e) request.GetResp onse ( );
    System.Text.Enc oding enc = System.Text.Enc oding.GetEncodi ng(1252); //
    Windows default Code Page
    System.IO.Strea mReader reader = new System.IO.Strea mReader(
    response.GetRes ponseStream(), enc );
    string content = reader.ReadToEn d();
    reader.Close();
    response.Close( );
    >
    I've tried different methods of StreamReader all with the same results.
    Can anyone tell me where the last 2KB of my response is going and how
    I can get it back?
    How sure are you that it's encoded in Windows-1252?

    --
    Jon Skeet - <skeet@pobox.co m>
    http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
    If replying to the group, please do not mail me too

    Comment

    • Dean Rettig

      #3
      Re: HttpWebResponse is truncated

      Jon,

      I thought of that.

      I've tried all of the popular encodings and plain raw binary and get
      the same thing. I think I'll try them all again just to make sure.

      I'm beginning to think that there is some latency/timeout that is
      causing the response to timeout and return before it has received all
      of the data.

      Dean

      On Jan 25, 4:00 pm, Jon Skeet [C# MVP] <s...@pobox.com wrote:
      Dean Rettig <retti...@gmail .comwrote:
      I am using HttpWebRequest to get an HttpWebResponse from an https://
      site.
      >
      I am using cookies and certificates and everything seems to be working
      properly EXCEPT...
      >
      The largest (html) document that I am trying to read is about 28788
      bytes when downloaded using Firefox
      >
      but when my dotnet app tries to retrieve it, the response is only about
      26580 bytes. Here is a code snippet:
      >
      HttpWebResponse response = (HttpWebRespons e) request.GetResp onse ( );
      System.Text.Enc oding enc = System.Text.Enc oding.GetEncodi ng(1252); //
      Windows default Code Page
      System.IO.Strea mReader reader = new System.IO.Strea mReader(
      response.GetRes ponseStream(), enc );
      string content = reader.ReadToEn d();
      reader.Close();
      response.Close( );
      >
      I've tried different methods of StreamReader all with the same results.
      Can anyone tell me where the last 2KB of my response is going and how
      I can get it back?How sure are you that it's encoded in Windows-1252?
      >
      --
      Jon Skeet - <s...@pobox.com >http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
      If replying to the group, please do not mail me too

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: HttpWebResponse is truncated

        On Jan 29, 4:37 pm, "Dean Rettig" <retti...@gmail .comwrote:
        I thought of that.
        >
        I've tried all of the popular encodings and plain raw binary and get
        the same thing. I think I'll try them all again just to make sure.
        >
        I'm beginning to think that there is some latency/timeout that is
        causing the response to timeout and return before it has received all
        of the data.
        That sounds unlikely. Have you looked at what's coming in over the
        network using something like Ethereal?

        Jon

        Comment

        • Dean Rettig

          #5
          Re: HttpWebResponse is truncated

          On Jan 29, 11:43 am, "Jon Skeet [C# MVP]" <s...@pobox.com wrote:
          On Jan 29, 4:37 pm, "Dean Rettig" <retti...@gmail .comwrote:
          >
          I thought of that.
          >
          I've tried all of the popular encodings and plain raw binary and get
          the same thing. I think I'll try them all again just to make sure.
          >
          I'm beginning to think that there is some latency/timeout that is
          causing the response to timeout and return before it has received all
          of the data.
          >
          That sounds unlikely. Have you looked at what's coming in over the
          network using something like Ethereal?
          >
          Jon
          Thanks Jon - I found the problem and it was unrelated to
          HttpWebRequest/Response.

          I was writing (some debuging info and) the output in a Textbox with
          the max string length set to 32768 which was clipping it.
          I increased the textbox max length to 1000000 and now I can see all of
          it.

          thanks for your ideas.

          Dean

          Comment

          Working...