473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HttpWebRequest method fails against Ravenous web server

1 New Member
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.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
  10.  
  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
  20.  
  21.     Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse()
  22.  
  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
  27.  
  28.     hwresponse.Close()
  29.   Catch e As Exception
  30.     responseData = "An error occurred: " & e.Message
  31.   End Try
  32.  
  33.   Return responseData
  34. End Function
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:

<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
0 1680

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

Similar topics

10
by: Ellen K | last post by:
Anyone have any tips for using Java against SQL Server? Our IT director is thinking of making us a Java shop, but I really would like to stay with SQL Server as our RDBMS. We have Oracle...
2
by: Steve H | last post by:
I have created an object in c# that produces script for a legacy ASP page. Next, I created a setup project and installed it on the server. When I run a page that accesses it from the server, I get...
4
by: Carl Williams | last post by:
Hope someone can help with this... I have looked at all the newsgroup articles and put into practice all the suggestions but to no good. I am pretty new to CSharp and .Net so any help would be...
2
by: Tom S | last post by:
I'm using ASP.NET with C# as my code behind and I figure out how to get the above process to work. I've found many examples online for using the 'method' member to "POST", but none for setting it...
0
by: piotrek | last post by:
Hi. Can anyone suggest me how to change path in GET method that is default method in my program? I need to change path from "/" to "/mypath". PK
8
by: Coy | last post by:
I've added the ASPNET user to my local SQL Server 2000, but I still get an unhandled exception: Login failed for user 'C594891-A\ASPNET'. This is when using a web service. A similiar ASP.NET...
3
by: PawelR | last post by:
Hello Group, How send few value using HttpWebReguest with POST method in one request? Thx. PawelR
8
by: rithish | last post by:
I am on IE 6. I was trying out a simple xmlhttp function that send GET/POST requests. However, IE throws an 'unspecified error' when I call the 'setRequestHeader' method. The function that I am...
0
by: Daniel | last post by:
System.Diagnostics.Process.Start fails on windows server 2003 the process returns process.ExitCode == 0 but executing any process with System.Diagnostics.Process.Start on windows xp works fine....
2
by: MedIt | last post by:
Hi All, I am trying to Post a number of requests to a web service on a client server from a console application.Through this application I am firing some 400 requests to the Web Service, one after...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.