HttpWebRequest.GetResponse() gives “HTTP protocol violation” error after .net frameworks service packs


This blog is valid for users of .Net frameworks 1.0 SP3 and .Net frameworks 1.1 SP1

The error is really because server is sending response with bad header format, which violates the http protocol specifications. These changes had been made to disallow bad headers. Bad http header could cause security vulnerability based on response-splitting and other attacks based on misinterpreting HTTP streams. 

However if your application still need to deal with such responses, you could roll back to old bahavior of relaxed header parsing. You need to use following app.config file.

<configuration>
      <system.net>
            <settings>
                  <httpWebRequest useUnsafeHeaderParsing=”true”/>
            </settings>
      </system.net>
</configuration>

This posting is provided “AS IS” with no warranties, and confers no rights

Comments (3)

  1. DinoCh says:

    I get this ("HTTP protocol violation") when communicating from .NET to the embedded HTTP server in my wireless access point, a Buffalo Airstation WLAR-L11-G.

    I built the app to automate the configuration of the thing. After a while, the router gets confused and it stops handing out DHCP addresses. With the utility, I can reset the router, via the wired connection, from a scheduled task.

    Anyway, the airstation is HTTP 1.0, as you said. I did not know about the config setting. I just try…catch.. the GetResponse() and check it to see if it is the expected protocol violation, and swallow the exception if it is.

  2. 楽しく、気持ちよく絶頂を味わえることで若い女性から熟女の女性まで幅広い世代で爆発的な人気がある、スローセックス。当サイトはプレイに興味がある、あるいは試してみたいけれど相手がいない…といった方の支援サイトです。当サイトでSEXパートナーを探してみませんか

  3. 出会い says:

    即ハメセレブは完全無料でご利用できる出会いコミュニティです。今までにない実績で、あなたの希望に合った人をお探しします。毎月考えられない豪華なイベントを開催しているので出会いを保障します

Skip to main content