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 1032123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:02:05+00:00 2026-05-16T14:02:05+00:00

I have a very simple class using HttpListener to receive an HTTP POST from

  • 0

I have a very simple class using HttpListener to receive an HTTP POST from a browser via an AJAX request. I’ve included a demo that highlights this issue:

private static void HandleRequest(HttpListenerContext context)
{
    using (var inputStream = context.Request.InputStream)
    {
        for (int i = 0; i < context.Request.ContentLength64; i++)
        {
            Console.WriteLine("{0}:\t{1}", i, inputStream.ReadByte());
        }
    }
 }

I also use the following Javascript in Firefox (using jQuery):

upload_html: function(html){
   jQuery.ajax({
            type: 'POST',
            data: html,
            url: 'http://localhost:8080/api/html?url=' + escape(content.document.location),
            success: function(data) {
                 // do stuff
            }
   });
}

The problem I’m having is that InputStream only ever contains around 900 bytes when sent from Firefox. If I place Fiddler between Firefox and my app, it correctly sends all 9,900 bytes. But when sending directly from Firefox to my app, only the first 900 chars (encoded as UTF8, so 900 bytes) are sent.

If I use curl to post data to my app, it works perfectly. Fiddler is also able to post data to my app and have it read correctly. Fiddler is able to read the data posted to it from Firefox, but my app can’t.

With different sizes of html, different amounts are sent, but it’s consistently the same size for the same pages. Regardless of size, it’s always between 899 and 999 bytes sent. If a page is under 900 bytes, it works and correctly reads all the data from the InputStream.

One theory I had was that it might be sending 1024 bytes, but the http headers were consuming some of those bytes, but the http headers are considerably larger than ~120 bytes.

One thing I should mention is that this JS is running from within a Firefox extension with jquery imported. I don’t think that’s causing the problem though, as I run into this same issue when running the same Javascript from within the page.

  • 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-05-16T14:02:05+00:00Added an answer on May 16, 2026 at 2:02 pm

    ReadToEnd works for me

    _RequestBody  = new StreamReader(_Context.Request.InputStream).ReadToEnd();
    

    and so does this for binary content

    var memoryStream = new MemoryStream();
    var buffer = new byte[0xFFFF];
    Stream stream = _Context.Request.InputStream;
    
    int i = 0;
    do {
      i = stream.Read(buffer, 0, 0xFFFF);
      memoryStream.Write(buffer, 0, i);
    } while (i > 0);
    memoryStream.Flush();
    memoryStream.Position = 0;
    return memoryStream;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple scenario, using NHibernate: one abstract base class animal; two
I have built a variety of little scripts using Ruby's very simple Queue class,
I have a very simple CGI webserver running using python CGIHTTPServer class. This class
I have a very simple xml string that I loaded using XmlDocument class. Now
I have a very simple migration which was created using the generator class AddEmailToUsers
I have a very simple java applet that I took from here: http://docs.oracle.com/javase/tutorial/deployment/applet/subclass.html import
I have a very simple class with some char* members. Is strcat the best
So I have a very simple class that has a method called getThumbUrl() but
I have this very simple C++ class: class Tree { public: Node *head; };
Let's say I have a very simple PrototypeJS class that looks like this: var

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.