webHttpRequest doesn't like my netgear router

D

DL

I'm trying to create a program to auto-reboot my netgear router when
my wireless connection goes down. I have no control over the
webserver installed on this machine (which is apparently violating the
HTTP protocol standard). I cannot snoop packets on this HTTP
connection because it forces an SSL-encrypted connection. I have
already made the config file change useUnsafeHeaderParsing="true",
which does not change the error message. (I also tried changing other
things in the config file to make sure it was being read).

Basically, I try to connect and I get the message "The underlying
connection was closed: The server commit
ted an HTTP protocol violation." What is odd is that I can connect
and pull down the main index page fine, but when I try to access the
login page, I get the error.

If anyone has any other thoughts besides the useUnsafeHeaderParsing
option, it would be greatly appreciated.

-DL

Here is my code:

// open new web client
WebClient client = new WebClient();


try
{
Stream data =
client.OpenRead("https://192.168.x.x/login.tri");
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
Console.WriteLine(s);
data.Close();
reader.Close();
}
catch (WebException ex)
{
Console.WriteLine(client.ResponseHeaders);
Console.WriteLine(ex.ToString());
}

And the error message:

System.Net.WebException: The underlying connection was closed: The
server commit
ted an HTTP protocol violation.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.OpenRead(String address)
at ping.Program.Main(String[] args)
System.Net.WebException: The underlying connection was closed: The
server commit
ted an HTTP protocol violation.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.OpenRead(String address)
at ping.Program.Main(String[] args)
 
J

Joerg Jooss

Thus wrote dl,
I'm trying to create a program to auto-reboot my netgear router when
my wireless connection goes down. I have no control over the
webserver installed on this machine (which is apparently violating the
HTTP protocol standard). I cannot snoop packets on this HTTP
connection because it forces an SSL-encrypted connection. I have
already made the config file change useUnsafeHeaderParsing="true",
which does not change the error message. (I also tried changing other
things in the config file to make sure it was being read).

Basically, I try to connect and I get the message "The underlying
connection was closed: The server commit
ted an HTTP protocol violation." What is odd is that I can connect
and pull down the main index page fine, but when I try to access the
login page, I get the error.
If anyone has any other thoughts besides the useUnsafeHeaderParsing
option, it would be greatly appreciated.

It would be interesting to see an actual HTTP message to understand what
causes the protocol violation.

Note that you can always code your own dirty litte HTTP client using Sockets
or TcpClient.

Cheers,
 
D

DL

It would be interesting to see an actual HTTP message to understand what
causes the protocol violation.

Is there a way to make WebClient dump that debug info? It doesn't
load anything into ResponseHeaders before the error happens, and
because of the SSL encryption I can't read anything in Ethereal.
Note that you can always code your own dirty litte HTTP client using Sockets
or TcpClient.

I guess I'm kind of worried how long it would take to get SSL
implemented if I went this route. Do sockets or tcpclient handle
this?
 
J

Joerg Jooss

Thus wrote dl,
Is there a way to make WebClient dump that debug info? It doesn't
load anything into ResponseHeaders before the error happens, and
because of the SSL encryption I can't read anything in Ethereal.

Sorry, I really missed the SSL part. You can always do it with a browser
plugin like LiveHttpHeaders for Firefox -- it runs after decryption.
I guess I'm kind of worried how long it would take to get SSL
implemented if I went this route. Do sockets or tcpclient handle
this?

..NET 2.0 comes with SslStream. For .NET 1.1 you have to use a third party
solution like Mentalis.org.

Cheers,
 
D

DL

Thus wrote dl,


Sorry, I really missed the SSL part. You can always do it with a browser
plugin like LiveHttpHeaders for Firefox -- it runs after decryption.

Thank you for the reference to LiveHttpHeaders. I realized by looking
at the post data that I was overlooking some javascript code that does
some MD5 calculation before posting back to the server. It still
throws a ServerProtocolViolation exception, but the post occurs and
access is granted to the administrative pages of the router.

-DL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top