473,382 Members | 1,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Why do I get "The server committed a protocol violation"?

I have an application that is making an HTTP request with
HttpWebRequest.GetRequest. Unless I set 'httpWebRequest
useUnsafeHeaderParsing="true"' in the web.config, I get a
'The server committed a protocol violation. Section=ResponseStatusLine' error.

Here is an example of the session that generates the error:

--- snip ---
GET <someURLHTTP/1.0

Host: <host>:<port>

Connection: Keep-Alive

HTTP/1.0 200 OK
Server: III 100
MIME-version: 1.0
Date: Tue, 13 Jan 1970 21:58:08 GMT
Expires: Wed, 19 Jul 2006 16:07:48 GMT
Content-Type: text/html; charset=UTF-8

<HTML><BODY>
RETCOD=0<BR>
</BODY></HTML>
--- snip ---

What is it about those headers in the HTTP response that is unsafe? Is it
the wacky date, or something more subtle?
Jul 18 '06 #1
3 8982

Hello Scott,

Thank you for posting in the MSDN newsgroup.

From your description, you're using the HttpWebRequest component to send
some http request to some external web resource in your ASP.NET web
application. However, you're always getting the "The server committed a
protocol violation. Section=ResponseStatusLine" error unless you set the
following section in the web.config file:

==========
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
==========

and you're wondering the cause of this behavior ,correct?

As for this issue, I've performed some research on this and found that the
problem is actually caused by the critical http header parsing/validating
of the HttpWebRequest component. According to the Http
Specification(http1.1), the HTTP header keys shoud specifically not include
any spaces in their names. However, some web servers do not fully respect
standards they're meant to. Applications running on the Dotnet framework
and making heavy use of http requests usually use the httpWebRequest class,
which encapsulates everything a web oriented developer could dream of. With
all the recently issues related to security, the "httpWebRequest" class
provides a self protection mechanism preventing it to accept HTTP answers
which not fully qualify to the specifications.

The common case is having a space in the "content-length" header key. The
server actually returns a "content length" key, which, assuming no spaces
are allowed, is considered as an attack vector (HTTP response split
attack), thus, triggering a "HTTP protocol violation error" exception.
And it is possible since the 1.1 SP 1 DotNet version to disable this error
check. Fortunately, DotNet allows you to modify some parameters directly
through a simple text configuration file :). and that's just the setting
you mentioned ealier in your message.

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

Hope this helps clarify this problem some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 19 '06 #2


#How to: Configure Network Tracing
http://msdn2.microsoft.com/en-us/library/ty48b824.aspx

#Interpreting Network Tracing
Jul 19 '06 #3
Hello Scott,

Just forget to mention that if you're developing under .net framework 2.0,
you can utilize the new Network Tracing feature to trace the processing in
those network components such as the classes in System.Net namespace. This
would be helpful for intercepting network component's communication:
#How to: Configure Network Tracing
http://msdn2.microsoft.com/en-us/library/ty48b824.aspx

#Interpreting Network Tracing
http://msdn2.microsoft.com/en-us/library/46fcs6sz.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: jblazi | last post by:
Let us assume I have a list like and would like to transoform it into the string '{1,2},{7,8},{12,13}' Which is the simplest way of achiebing this? (The list is in fact much longer and...
0
by: Oliver | last post by:
hi - I have a written a "Serviced Component" which works fine when declared as: but I am seeing an 'Access Denied' exception when I declare it as: this is probably something to do with...
6
by: eXseraph | last post by:
Hi, As we know,in normal asp.net application, a browser need to send a request to a server first to refresh its page. Now I need to design a asp.net application with real-time capability like the...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
2
by: Wimpie van Lingen | last post by:
Hey I have some more questions with regards to Remoting in .NET 2. I'm using TCP with the Binary formatter. My solution consists of 4 projects: - Class Library containing the server classes...
0
by: oriol.ardevol | last post by:
Hi, I have an asp.net application that connects through an HttpWebRequest object to a ISAPI dll in a server. This isapi dll has some different method calls. What I do is calling the different...
4
by: Sin Jeong-hun | last post by:
I don't get the message so it's hard to debug that, but some of my clients report that they get "The underlying connection was closed unexpectedly" exception. According to this site (http://...
0
by: johnyjj2 | last post by:
Hello! I'd like to run mssql script (file with extension sql). I installed Microsoft SQL Server 2008 and run in Command Prompt: C:\Documents and Settings\useruser>osql -Usa -Ppassword -i...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.