I have a very simple class using an HttpListener to get HTTP POST from a browser through an AJAX request. I 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) {
}
});
}
The problem I am facing is that an InputStream only ever contains about 900 bytes when sent from Firefox. If I put Fiddler between Firefox and my application, it will send all 9,900 bytes correctly. But when sending directly from Firefox, only the first 900 characters are sent to my application (encoded as UTF8, so 900 bytes).
curl , . Fiddler . Fiddler , Firefox, .
html , . , 899 999 . 900 , InputStream.
, , , 1024 , http , HTTP , ~ 120 .
, , , JS Firefox jquery. , , Javascript .