By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,948 Members | 1,103 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,948 IT Pros & Developers. It's quick & easy.

HttpWebRequest method fails against Ravenous web server

P: 1
I am attempting to retrieve the response stream from a Ravenous web server ( without success. I consistenly get the following error:

System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine

The code I am using is as follows:

Expand|Select|Wrap|Line Numbers
  1. Function WRequest(URL As String, method As String, POSTdata As String) As String
  2.   Dim responseData As String = ""
  3.   Try
  4.     Dim hwrequest As Net.HttpWebRequest = Net.Webrequest.Create(URL)
  5.     hwrequest.Accept = "*/*"
  6.     hwrequest.AllowAutoRedirect = True
  7.     hwrequest.UserAgent = "http_requester/0.1"
  8.     hwrequest.Timeout = 60000
  9.     hwrequest.Method = method
  11.     If hwrequest.Method = "POST" Then
  12.       hwrequest.ContentType = "application/x-www-form-urlencoded"
  13.       Dim encoding As New System.Text.ASCIIEncoding() 'Use UTF8Encoding for XML requests
  14.       Dim postByteArray() As Byte = encoding.GetBytes(POSTdata)
  15.       hwrequest.ContentLength = postByteArray.Length
  16.       Dim postStream As IO.Stream = hwrequest.GetRequestStream()
  17.       postStream.Write(postByteArray, 0, postByteArray.Length)
  18.       postStream.Close()
  19.     End If
  21.     Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse()
  23.     If hwresponse.StatusCode = Net.HttpStatusCode.OK Then
  24.       Dim responseStream As IO.StreamReader = New IO.StreamReader(hwresponse.GetResponseStream())
  25.       responseData = responseStream.ReadToEnd()
  26.     End If
  28.     hwresponse.Close()
  29.   Catch e As Exception
  30.     responseData = "An error occurred: " & e.Message
  31.   End Try
  33.   Return responseData
  34. End Function
This code works fine for requests against, and other websites I have tried but any request against a Ravenous web server fails with the above error.

I have tried modifying the app.config like so:

<httpWebRequest useUnsafeHeaderParsing = "true"/>

with no joy.

I have searched and searched the web for answers, trying all different types of code and app.config modifications without success. Does anyone have any experience with a Ravenous web server?
Jan 23 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.