Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

webHttpRequest doesn't like my netgear router

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DL - 17 Mar 2006 17:27 GMT
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)
Joerg Jooss - 17 Mar 2006 18:38 GMT
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
[quoted text clipped - 12 lines]
> 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,
Signature

Joerg Jooss
news-reply@joergjooss.d

DL - 17 Mar 2006 19:31 GMT
>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?

>Cheers,
Joerg Jooss - 17 Mar 2006 19:52 GMT
Thus wrote 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.

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,
Signature

Joerg Jooss
news-reply@joergjooss.d

DL - 20 Mar 2006 14:16 GMT
>Thus wrote dl,
>
[quoted text clipped - 7 lines]
>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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.