473,785 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpWebRequest Exception on HTTP/1.0 204 No Content

Hi,

I'm currently coding in C# a class to control a PTZ (Pan Tilt Zoom)
Camera. To control the camera I have to send request on a CGI on it.

Something like this :

http://xxxxxx/axis-cgi/com/ptz.cgi?pan=100 (GET method) or using POST.

To do that I'm using the HttpWebRequest and HttpWebResponse class of
Microsoft .Net Framework 1.1.

Here is my code :

try
{
HttpWebRequest l_Req =
(HttpWebRequest )WebRequest.Cre ate(m_PtzUri.To String());
//construct header
l_Req.Headers.C lear();
l_Req.KeepAlive = false;
l_Req.Timeout = 2000;
l_Req.Method = "POST"; // POST or GET
string sMessage = _CommandLine;
l_Req.ContentLe ngth = sMessage.Length ;

//convert login:password to Base64 string
Encoding asciiEncoding = Encoding.ASCII;
byte[] byteArray = new byte[m_PtzUri.UserIn fo.Length];
byteArray = asciiEncoding.G etBytes(m_PtzUr i.UserInfo);

//Camera are using Authorization Basic
l_Req.Headers.A dd("Authorizati on", "Basic " +
Convert.ToBase6 4String(byteArr ay));
//standard url encode
l_Req.ContentTy pe = "applicatio n/x-www-form-urlencoded";

//write the post in the stream
Stream l_StreamReq = l_Req.GetReques tStream();
StreamWriter l_SWriter = new StreamWriter(l_ StreamReq);
l_SWriter.Write (sMessage);
l_SWriter.Flush ();

//send the request now, synchronous ! (Wait for answer)
HttpWebResponse l_Resp = (HttpWebRespons e)l_Req.GetResp onse();

//read the answer
if(l_Resp.Statu sCode == HttpStatusCode. NoContent)
LogViewer.Write Line(LogViewer. MessageType.Inf o, "Send",
_CommandLine);
l_StreamReq.Clo se();
}
catch(WebExcept ion e)
{
LogViewer.Write Line(LogViewer. MessageType.Exc eption, "WebExcepti on",
e.ToString());
return false;
}

When the command is send, the camera returns a HTTP/1.0 204 No Content
which means (RFC1945) :

204 No Content : The server has fulfilled the request but there is no
new information to send back.

Here is a ethereal capture :

[Client Request]
POST /axis-cgi/com/ptz.cgi HTTP/1.1
Authorization: Basic cm9vdDpsdHM1Y2F tZQ==
Content-Type: application/x-www-form-urlencoded
Content-Length: 6
Expect: 100-continue
Connection: Close
Host: xxxxxx
pan=0

[Server Response]
HTTP/1.0 204 No Content

So my problem is, the camera is moving, the reponse is send back as we
can see on ethereal capture. But the following line threws a TimeOut
Exception like if it didn't understand the HTTP/1.0 204 No Content :

HttpWebResponse l_Resp = (HttpWebRespons e)l_Req.GetResp onse();
Anyone can help me on this ? Thanks.

Christophe

Nov 22 '05 #1
3 5772

no need to use that class.

just use javascript http request to send a header value to the asp.net page
and do a request header in the asp.net page. to send back the value just to a
response.write in the asp.net page and catch this in the javascript page.

I have used the http request like this ;-)

greets,
"su*******@gmai l.com" wrote:
Hi,

I'm currently coding in C# a class to control a PTZ (Pan Tilt Zoom)
Camera. To control the camera I have to send request on a CGI on it.

Something like this :

http://xxxxxx/axis-cgi/com/ptz.cgi?pan=100 (GET method) or using POST.

To do that I'm using the HttpWebRequest and HttpWebResponse class of
Microsoft .Net Framework 1.1.

Here is my code :

try
{
HttpWebRequest l_Req =
(HttpWebRequest )WebRequest.Cre ate(m_PtzUri.To String());
//construct header
l_Req.Headers.C lear();
l_Req.KeepAlive = false;
l_Req.Timeout = 2000;
l_Req.Method = "POST"; // POST or GET
string sMessage = _CommandLine;
l_Req.ContentLe ngth = sMessage.Length ;

//convert login:password to Base64 string
Encoding asciiEncoding = Encoding.ASCII;
byte[] byteArray = new byte[m_PtzUri.UserIn fo.Length];
byteArray = asciiEncoding.G etBytes(m_PtzUr i.UserInfo);

//Camera are using Authorization Basic
l_Req.Headers.A dd("Authorizati on", "Basic " +
Convert.ToBase6 4String(byteArr ay));
//standard url encode
l_Req.ContentTy pe = "applicatio n/x-www-form-urlencoded";

//write the post in the stream
Stream l_StreamReq = l_Req.GetReques tStream();
StreamWriter l_SWriter = new StreamWriter(l_ StreamReq);
l_SWriter.Write (sMessage);
l_SWriter.Flush ();

//send the request now, synchronous ! (Wait for answer)
HttpWebResponse l_Resp = (HttpWebRespons e)l_Req.GetResp onse();

//read the answer
if(l_Resp.Statu sCode == HttpStatusCode. NoContent)
LogViewer.Write Line(LogViewer. MessageType.Inf o, "Send",
_CommandLine);
l_StreamReq.Clo se();
}
catch(WebExcept ion e)
{
LogViewer.Write Line(LogViewer. MessageType.Exc eption, "WebExcepti on",
e.ToString());
return false;
}

When the command is send, the camera returns a HTTP/1.0 204 No Content
which means (RFC1945) :

204 No Content : The server has fulfilled the request but there is no
new information to send back.

Here is a ethereal capture :

[Client Request]
POST /axis-cgi/com/ptz.cgi HTTP/1.1
Authorization: Basic cm9vdDpsdHM1Y2F tZQ==
Content-Type: application/x-www-form-urlencoded
Content-Length: 6
Expect: 100-continue
Connection: Close
Host: xxxxxx
pan=0

[Server Response]
HTTP/1.0 204 No Content

So my problem is, the camera is moving, the reponse is send back as we
can see on ethereal capture. But the following line threws a TimeOut
Exception like if it didn't understand the HTTP/1.0 204 No Content :

HttpWebResponse l_Resp = (HttpWebRespons e)l_Req.GetResp onse();
Anyone can help me on this ? Thanks.

Christophe

Nov 22 '05 #2
As written in my post I'm coding a C# Application.

Anyway thanks for replying.

Nov 22 '05 #3
C# is a language. wich can be used in a web environment and/or windows.

"su*******@gmai l.com" wrote:
As written in my post I'm coding a C# Application.

Anyway thanks for replying.

Nov 22 '05 #4

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

Similar topics

10
19361
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
3
750
by: superseed | last post by:
Hi, I'm currently coding in C# a class to control a PTZ (Pan Tilt Zoom) Camera. To control the camera I have to send request on a CGI on it. Something like this : http://xxxxxx/axis-cgi/com/ptz.cgi?pan=100 (GET method) or using POST. To do that I'm using the HttpWebRequest and HttpWebResponse class of
3
15756
by: ME | last post by:
Hi; I am getting "Unhandled Exception: System.Net.WebException: The remote server returned an erro r: (401) Unauthorized." when I am trying to get a page via post. Code follows...
1
2813
by: ATS | last post by:
PRB - HttpWebRequest does not work with CGI websites and/or RAW data Please help, I'm trying to make a web deploying UserControl that gets RAW binary data that is dynamically created from a CGI application webiste, and have the UserControl write the data down to a file. I've used the code listed here after to make this happen. If I plug in a URL to a non-CGI site, such as a static HTML page, the UserControl successfully get the output...
1
1633
by: iana_kosio | last post by:
Hi, I am using HttpWebRequest class to communicate with remote server. In some cases the server would return 5xx status code which results in HttpWebRequest object throwing an exception. I, however, still need to access the response stream from the server as it contains information that I need. Any ideas how I can do that? Thanks, Konstantin try { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost/myUrl");
0
1562
by: boxboy | last post by:
Hi, I'm writing a console application and am having a problem with HttpWebRequest when posting data to a webserver. A "System.Net.WebException: The server committed a protocol violation" is always being thrown when getting the response from a specific host. I'm pretty sure the framework's implementation doesn't like the formating or status code of the returned response header. It throws the exception without giving me a way of handling it...
1
4718
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 don't know why. The application screen scrapes a web page. If I paste the URL in my browser's address bar and the expected page comes up just fine. When I went through the hassle of getting the real response from within the exception object,...
4
12712
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 advices but still having troubles... it might some obvious error that I am making but I just dont see it. ==================FIRST - Webclient=================================
0
1403
by: BillE | last post by:
VS2005 VB.net I'm using the HTTPWebRequest class to connect to a web site with SSL. I first manually connected to the site and installed the certificate on my computer, and then use the X509Certificate class to add the certificate to the HTTPWebRequest, but I continue to get the exception: "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."
1
8047
by: Proogeren | last post by:
I have a problem with a httpwebrequest that I am creating. The request in itself looks correct but using fiddler I see that a www-authentication header is sent along as well. The code is pasted below. I do not add any www-authentication header here so I was wondering if anyone knows how to remove it. I have used almost 2 days trying to figure this out so help would be highly appreciated. CORRECT No proxy-authenticate header is present no...
0
10350
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.