<p>A J2ME client is sending HTTP POST requests with chunked transfer encoding.</p>

<p>When ASP.NET (in both IIS6 and WebDev.exe.server) tries to read the request it sets the Content-Length to 0. I guess this is ok because the Content-length is unknown when the request is loaded.</p>

<p>However, when I read the Request.InputStream to the end, it returns 0.</p>

<p>Here's the code I'm using to read the input stream.</p>

<pre><code>using (var reader = new StreamReader(httpRequestBodyStream, BodyTextEncoding)) {
    string readString = reader.ReadToEnd();
    Console.WriteLine("CharSize:" + readString.Length);
    return BodyTextEncoding.GetBytes(readString);
}
</code></pre>

<p>I can simulate the behaiviour of the client with Fiddler, e.g.</p>

<p><strong>URL</strong>
<a href="http://localhost:15148/page.aspx" rel="nofollow noreferrer">http://localhost:15148/page.aspx</a></p>

<p><strong>Headers:</strong>
User-Agent: Fiddler
Transfer-Encoding: Chunked
Host: somesite.com:15148</p>

<p><strong>Body</strong>
rabbits rabbits rabbits rabbits. thanks for coming, it's been very useful!</p>

<p>My body reader from above will return a zero length byte array...lame...</p>

<p>Does anyone know how to enable chunked encoding on IIS and ASP.NET Development Server (cassini)?</p>

<p>I found <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;278998" rel="nofollow noreferrer">this script</a> for IIS but it isn't working.</p>

[{'answer_id': 80576, 'author': 'Andrew', 'author_id': 15127, 'author_profile': 'https://Stackoverflow.com/users/15127', 'pm_score': 1, 'selected': False, 'text': '<p>That url does not work any more, so it\'s hard to test this directly.  I wondered if this would work, and google turned up someone who has experience with it at <a href="http://bytes.com/forum/thread246706.html" rel="nofollow noreferrer">bytes.com</a>.  If you put your website up again, I can see if this really works there.  </p>\n\n<p><strong>Joerg Jooss</strong> wrote: (<em>slightly modified for brevity</em> )</p>\n\n<pre><code>string responseText = null;\nWebRequest rabbits= WebRequest.Create(uri);\nusing (Stream resp = rabbits.GetResponse().GetResponseStream()) {\n    MemoryStream memoryStream = new MemoryStream(0x10000);\n    byte[] buffer = new byte[0x1000];\n    int bytes;\n    while ((bytes = resp.Read(buffer, 0, buffer.Length)) &gt; 0) {\n        memoryStream.Write(buffer, 0, bytes);\n    }\n    // use the encoding to match the data source.\n    Encoding enc = Encoding.UTF8;\n    reponseText = enc.GetString(memoryStream.ToArray());\n}\n</code></pre>\n'}, {'answer_id': 4294031, 'author': 'Anton Tykhyy', 'author_id': 77724, 'author_profile': 'https://Stackoverflow.com/users/77724', 'pm_score': 2, 'selected': False, 'text': '<p>Seems to be official: <a href="http://msdn.microsoft.com/en-us/library/ee960144.aspx" rel="nofollow">Cassini does not support <code>Transfer-Encoding: chunked</code> requests.</a></p>\n\n<blockquote>\n  <p>By default, the client sends large\n  binary streams by using a chunked HTTP\n  Transfer-Encoding. <strong>Because the ASP.NET\n  Development Server does not support\n  this kind of encoding</strong>, you cannot use\n  this Web server to host a streaming\n  data service that must accept large\n  binary streams.</p>\n</blockquote>\n'}]
['https://Stackoverflow.com/questions/69104', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/209/']