I am attempting to retrieve the response stream from a Ravenous web server (http://ostatic.com/ravenous) without success. I consistenly get the following error:
System.Net.WebE xception: The server committed a protocol violation. Section=Respons eStatusLine
The code I am using is as follows:
This code works fine for requests against Yahoo.com, Google.com 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:
<httpWebReque st useUnsafeHeader Parsing = "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?
System.Net.WebE xception: The server committed a protocol violation. Section=Respons eStatusLine
The code I am using is as follows:
Code:
Function WRequest(URL As String, method As String, POSTdata As String) As String Dim responseData As String = "" Try Dim hwrequest As Net.HttpWebRequest = Net.Webrequest.Create(URL) hwrequest.Accept = "*/*" hwrequest.AllowAutoRedirect = True hwrequest.UserAgent = "http_requester/0.1" hwrequest.Timeout = 60000 hwrequest.Method = method If hwrequest.Method = "POST" Then hwrequest.ContentType = "application/x-www-form-urlencoded" Dim encoding As New System.Text.ASCIIEncoding() 'Use UTF8Encoding for XML requests Dim postByteArray() As Byte = encoding.GetBytes(POSTdata) hwrequest.ContentLength = postByteArray.Length Dim postStream As IO.Stream = hwrequest.GetRequestStream() postStream.Write(postByteArray, 0, postByteArray.Length) postStream.Close() End If Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse() If hwresponse.StatusCode = Net.HttpStatusCode.OK Then Dim responseStream As IO.StreamReader = New IO.StreamReader(hwresponse.GetResponseStream()) responseData = responseStream.ReadToEnd() End If hwresponse.Close() Catch e As Exception responseData = "An error occurred: " & e.Message End Try Return responseData End Function
I have tried modifying the app.config like so:
<httpWebReque st useUnsafeHeader Parsing = "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?