Home All Groups Group Topic Archive Search About

webHttpRequest doesn't like my netgear router

Author
17 Mar 2006 4:27 PM
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)

Author
17 Mar 2006 5:38 PM
Joerg Jooss
Thus wrote dl,

Show quote
> 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,
--
Joerg Jooss
news-re***@joergjooss.de
Author
17 Mar 2006 6:31 PM
DL
On Fri, 17 Mar 2006 17:38:00 +0000 (UTC), Joerg Jooss
<news-re***@joergjooss.de> wrote:
>
>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?

Show quote
>
>Cheers,
Author
17 Mar 2006 6:52 PM
Joerg Jooss
Thus wrote dl,

> On Fri, 17 Mar 2006 17:38:00 +0000 (UTC), Joerg Jooss
> <news-re***@joergjooss.de> wrote:
>
>> 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.

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

>> 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?

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

Cheers,
--
Joerg Jooss
news-re***@joergjooss.de
Author
20 Mar 2006 1:16 PM
DL
On Fri, 17 Mar 2006 18:52:22 +0000 (UTC), Joerg Jooss
<news-re***@joergjooss.de> wrote:

Show quote
>Thus wrote dl,
>
>> On Fri, 17 Mar 2006 17:38:00 +0000 (UTC), Joerg Jooss
>> <news-re***@joergjooss.de> wrote:
>>
>>> 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.
>
>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

AddThis Social Bookmark Button