473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

httpwebrequest for no http headers

I have a hardware device that I need to read from. To connect to it
you do a http://<name>/data and it return a few string of raw data(non-
HTML format and no HTTP header). I just need to put that full return
into a string and I would be good to go.

I orginally tried WebClient and had problems so rewrote to
HttpWebRequest for better control. Code will work on properly formed
web pages. Based on recommendations to other error message I have
added the KeepAlive = false and set the useUnsafeHeaderParsing to
true. Doing that remove other problems and now I am stuck with the
WebExeception of

"The underlying connection was closed: The connection was closed
unexpectedly."

That the page returns a few string of non-HTML, and no HTTP header,
the error message is not totally unreasonable.

Are there any methods or properties that will allow me to get the page
in its raw format, or do I have to write my own code to connect to the
port and handle the request?

Mar 27 '07 #1
1 2215
Will,

Honestly, for something like this, which doesn't adhere to the HTTP
standard, I wouldn't bother using the HttpWebRequest/HttpWebResponse
classes.

Rather, I would just use the Socket class and connect directly to the
resource. Sending the request is easy enough, and getting the response will
be a matter of just reading off the socket.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Will" <wd******@rmi.netwrote in message
news:11**********************@b75g2000hsg.googlegr oups.com...
>I have a hardware device that I need to read from. To connect to it
you do a http://<name>/data and it return a few string of raw data(non-
HTML format and no HTTP header). I just need to put that full return
into a string and I would be good to go.

I orginally tried WebClient and had problems so rewrote to
HttpWebRequest for better control. Code will work on properly formed
web pages. Based on recommendations to other error message I have
added the KeepAlive = false and set the useUnsafeHeaderParsing to
true. Doing that remove other problems and now I am stuck with the
WebExeception of

"The underlying connection was closed: The connection was closed
unexpectedly."

That the page returns a few string of non-HTML, and no HTTP header,
the error message is not totally unreasonable.

Are there any methods or properties that will allow me to get the page
in its raw format, or do I have to write my own code to connect to the
port and handle the request?

Mar 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Craig | last post by:
I wrote a generic page to do HttpWebRequest operations based on 3 querystring parameters for the uri, username, and password for basic authentication pages. The page is designed to help with...
16
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the...
0
by: Peter Qian | last post by:
Hi, I'm working on a windows form based program that can log into a web service (Apache based, https is used for auth). I was able to post the login data and obtain a sessionID. However I'm not...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
0
by: Alex Papadimoulis | last post by:
Hey Group, I'm in the process of converting an ASP-based site to an ASP.NET site and built a control that wraps around an ASP page. The control simply does a GET to the same server to render the...
1
by: mfreeman | last post by:
I have a VB.NET 2005 Windows application that worked fine when I ran it a month ago, and now it is throwing an exception ("The remote server returned an error: (500) Internal Server Error.") and I...
4
by: Natalia | last post by:
Hello, I need to provide the ability to post file and some form elements via our website (asp.net) to the third party website (asp page). On http://aspalliance.com/236#Page4 - I found great...
0
by: barrybevel | last post by:
Hi, I'm trying to login to the www.vodafone.ie website using HttpWebRequest. It works fine with IE/Firefox and the .NET Web Control too, just not with my code. I think it's a redirect 302...
3
by: stoogots2 | last post by:
Hi, I was using the WebClient class (to do some screen scraping) and I was forced to change to the HttpWebRequest/Response because I needed control over the http headers. I am having two problems...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.