System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine
The code I am using is as follows:
Expand|Select|Wrap|Line Numbers
- 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:
<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?