I have tried a number of ways and I get this error:
The server committed a protocol violation. Section=ResponseStatusLine
I am reading a CSV file from a deprag controller running linux.
My code on win7 is as follows:
textBox2.Text = "starting...";
HttpWebRequest request =
textBox1.Text = http://126.96.36.199/cgi-bin/cgiread?site=13&dlfile=/mnt/mmc/finaldata/Actual.csv
// Set some reasonable limits on resources used by
request.ServicePoint.Expect100Continue = false;
request.MaximumAutomaticRedirections = 4;
request.MaximumResponseHeadersLength = 4;
WebResponse response =
(WebResponse)request.GetResponse(); // crashes here
fromcache.Checked = response.IsFromCache;
long length = response.ContentLength;
string contentType = response.ContentType;
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader
with the required encoding format.
StreamReader readStream = new
label2.Text = readStream.ReadToEnd();
textBox2.Text = "completed!";
catch (Exception ee)
textBox2.Text = ee.Message;
s used by
and the file read contains of one line only:
works in any browser
El jueves 8 de marzo de 2012 16:47:57 UTC+1, Sonnich Jensen escribi=F3:
ces used by
- Check http server log to check if the respose status code is the expected=
- Sniff http request and server response to find out strange things
Seems like the server is not returning a valid http status code or a not su=
El jueves 8 de marzo de 2012 16:58:47 UTC+1, bradbury9 escribi=F3:
urces used by
e =3D false;
You can check the .net framework supported status codes at msdn: http://msd=
Proxy settings and user autentification are usually things to take into con=
sideration that can make IE and FF showing content right and .NET giving ex=
ceptions. But I think it is a differet one because of the "protocol violati=
on. Section=3DResponseStatus" message.
You use textBox1.Text before giving it a value??
No, it has the value given here - as you see the quotes are missing.
The textbox is so I can use my range of Deprag's, I have 10 of them
with different IPs....
sources used by
nue =3D false;
s =3D 4;
h =3D 4;
el stream reader
t supported one.
onsideration that can make IE and FF showing content right and .NET giving =
exceptions. But I think it is a differet one because of the "protocol viola=
tion. Section=3DResponseStatus" message.
Well, the GetResponse crashes, so I never get any code.
The value does not get set, so I dont get any data....
El viernes 9 de marzo de 2012 12:50:07 UTC+1, Sonnich Jensen escribi=F3:
resources used by
tinue =3D false;
ons =3D 4;
gth =3D 4;
evel stream reader
not supported one.
consideration that can make IE and FF showing content right and .NET givin=
g exceptions. But I think it is a differet one because of the "protocol vio=
lation. Section=3DResponseStatus" message.
That is the reason I told you to check the server logs or sniff the http tr=
afic between the client and the server ;-)
Den 09.03.2012 12:04, skrev Sonnich Jensen:
Have you tried using WebClient and let the OS take care of the low-level
using (WebClient wc = new WebClient())
label2.Text = wc.DownloadString(textBox1.Text);
catch (WebException ex)
textBox2.Text = ex.Message;
Den 09.03.2012 13:42, skrev Bj?rn Brox:
I would also have checked if the URL is correct, because the argument
dlfile=/mnt/mmc/finaldata/Actual.csv soes not seem to be a Linux file
path (which would use \mnt\mmc\... )
You are wrong. Linux path delimiter is / and you tell him it is \ so file p=
ath would be /mnt/mmc/...
May be strange, but is one thing I like about Linux, Unix and BSD OS's.
BTW: that absolute path looks like a nasty security bug.
Den 09.03.2012 13:55, skrev bradbury9:
You are correct.
Den 09.03.2012 13:55, skrev bradbury9:
Sorry, I mixed a bit.
Absolutely, but I doubt that any webserver would give root access, which
again raises the question: Are you sure that the path are correct, -
seen from the outside?
/mnt/mmc/ seems to be some sort of card reader device mount point and most =
likely it would be mounted with big privileges (unless they did chgroup the=
mount point and made it rw for apache user). If they do:
And it works with that path you have a potencial security bug :-D
That tricked me.
But even if it had been the case then one usually use / in
URL's and translate to OS specific path server side. Also
for file name query parameters.