views:

774

answers:

0

HttpWebRequest is used to download files from ASP.NET site with basic authentication. Everything works fine in much cases. But some proxies make answer chunked and HttpWebRequest.GetResponse() throws an exception if answer with 401 code is chunked. The exception is: System.Net.WebException: The server committed a protocol violation.
Section=ResponseStatusLine at System.Net.HttpWebRequest.GetResponse() Trace of answer is: "HTTP/1.1 401 Authorization Required\r\nDate: Fri, 26 Jun 2009 04:45:18 GMT\r\nServer: Microsoft-IIS/6.0\r\nX-Powered-By: ASP.NET\r\nX-AspNet-Version: 2.0.50727\r\nWWW-Authenticate: Basic realm=\"iis-server\"\r\nCache-Control: private\r\nContent-Type: text/html; charset=iso-8859-1\r\nVia: 1.1 server\r\nKeep-Alive: timeout=15, max=100\r\nConnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\nContent-Language: en\r\n\r\n0\r\n\r\n0\r\n\r\n" I made test and found out that "Transfer-Encoding: chunked" is the only one reason of exception. Is this bug of .NET Framework 2.0 or there any RFC says that 401 answer shouldn't be chunked?