An alternative of HttpWebRequest/HttpWebResponse

G

Guest

I used HttpWebRequest/HttpWebResponse to get the content of an URL. It throws
"HTTP Protocol Violation" sometimes. And I set useUnsafeHeaderParsing =
"true" to fix the problem in most case, but for some cases, it does not fix
the problem.

I know there are some problems in server, but I cannot control the server,
and the content shows well in IE. (My content-type is text/plain)

My question is there an alternative way to get content of the URL? I
remember I did something in Perl five years before, Can we use other way in
..NET? I have hoped Microsoft can fix the well-know problem, looks like the
problem remain in framework 2.0

Thanks
 
N

Nicholas Paldino [.NET/C# MVP]

Qingdong,

It doesn't seem like it is a problem in .NET. From the error, it seems
like the server is returning a response which violates the expected problem.
It is possible that the code is wrong. Can you provide a website where the
classes don't work?

IE is much more tolerant of these things, so it shouldn't be used as a
comparison point. It's expected to be more tolerant.

As for alternatives, you can always use a socket and send the request
yourself, and read/parse the response.

You might try the indy project (http://www.indyproject.org), they
^might^ have something there.

Hope this helps.
 
G

Guest

Nicholas,

I used my local Axis Network Camera.
http://MyIP/axis-cgi/com/ptz.cgi?query=presetposall

But mean while, this works
http://MyIP/axis-cgi/com/ptz.cgi?move=left

Anyways, I still need advice on the alternative method to get content of URL.

Thanks.





Nicholas Paldino said:
Qingdong,

It doesn't seem like it is a problem in .NET. From the error, it seems
like the server is returning a response which violates the expected problem.
It is possible that the code is wrong. Can you provide a website where the
classes don't work?

IE is much more tolerant of these things, so it shouldn't be used as a
comparison point. It's expected to be more tolerant.

As for alternatives, you can always use a socket and send the request
yourself, and read/parse the response.

You might try the indy project (http://www.indyproject.org), they
^might^ have something there.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Qingdong Z. said:
I used HttpWebRequest/HttpWebResponse to get the content of an URL. It
throws
"HTTP Protocol Violation" sometimes. And I set useUnsafeHeaderParsing =
"true" to fix the problem in most case, but for some cases, it does not
fix
the problem.

I know there are some problems in server, but I cannot control the server,
and the content shows well in IE. (My content-type is text/plain)

My question is there an alternative way to get content of the URL? I
remember I did something in Perl five years before, Can we use other way
in
.NET? I have hoped Microsoft can fix the well-know problem, looks like the
problem remain in framework 2.0

Thanks
 
N

Nicholas Paldino [.NET/C# MVP]

Qingdong,

We can't really test that, unfortunately.

The original email has some alternatives you can use.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Qingdong Z. said:
Nicholas,

I used my local Axis Network Camera.
http://MyIP/axis-cgi/com/ptz.cgi?query=presetposall

But mean while, this works
http://MyIP/axis-cgi/com/ptz.cgi?move=left

Anyways, I still need advice on the alternative method to get content of
URL.

Thanks.





Nicholas Paldino said:
Qingdong,

It doesn't seem like it is a problem in .NET. From the error, it
seems
like the server is returning a response which violates the expected
problem.
It is possible that the code is wrong. Can you provide a website where
the
classes don't work?

IE is much more tolerant of these things, so it shouldn't be used as
a
comparison point. It's expected to be more tolerant.

As for alternatives, you can always use a socket and send the request
yourself, and read/parse the response.

You might try the indy project (http://www.indyproject.org), they
^might^ have something there.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Qingdong Z. said:
I used HttpWebRequest/HttpWebResponse to get the content of an URL. It
throws
"HTTP Protocol Violation" sometimes. And I set useUnsafeHeaderParsing =
"true" to fix the problem in most case, but for some cases, it does not
fix
the problem.

I know there are some problems in server, but I cannot control the
server,
and the content shows well in IE. (My content-type is text/plain)

My question is there an alternative way to get content of the URL? I
remember I did something in Perl five years before, Can we use other
way
in
.NET? I have hoped Microsoft can fix the well-know problem, looks like
the
problem remain in framework 2.0

Thanks
 
G

Guest

Nicholas,

HTTP Response has some problem definitely. Here is the information I
captured from IE, looks like have problems e.g. --A segment before this
frame was lost---

Here is the all information, I don't know if you can find the problem from
the response. Thanks.


Packetyzer Trace:

Frame 1 (142 bytes on wire, 142 bytes captured)
Frame is marked: False
Arrival Time: Jan 16, 2006 15:04:48.409056000
Time delta from previous packet: -1.079698000 seconds
Time since reference or first frame: 111.041423000 seconds
Frame Number: 1
Packet Length: 142 bytes
Capture Length: 142 bytes
Protocols in frame: eth:ip:tcp:http:data
Ethernet II, Src: 00:40:10:18:b8:28, Dst: 00:0c:f1:bc:5d:08
Destination: 00:0c:f1:bc:5d:08 (Intel_bc:5d:08)
Source: 00:40:10:18:b8:28 (Sonic_18:b8:28)
Source or Destination Address: 00:0c:f1:bc:5d:08 (Intel_bc:5d:08)
Source or Destination Address: 00:40:10:18:b8:28 (Sonic_18:b8:28)
Type: IP (0x0800)
Internet Protocol, Src Addr: 10.10.1.237 (10.10.1.237), Dst Addr:
172.17.0.56 (172.17.0.56)
Version: 4
Header length: 20 bytes
Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
0000 00.. = Differentiated Services Codepoint: Default (0x00)
.... ..0. = ECN-Capable Transport (ECT): 0
.... ...0 = ECN-CE: 0
Total Length: 128
Identification: 0xa66f (42607)
Flags: 0x04 (Don't Fragment)
0... = Reserved bit: Not set
.1.. = Don't fragment: Set
..0. = More fragments: Not set
Fragment offset: 0
Time to live: 64
Protocol: TCP (0x06)
Header checksum: 0xdbc8 (correct)
Source: 10.10.1.237 (10.10.1.237)
Source or Destination Address: 10.10.1.237 (10.10.1.237)
Destination: 172.17.0.56 (172.17.0.56)
Source or Destination Address: 172.17.0.56 (172.17.0.56)
Transmission Control Protocol, Src Port: http (80), Dst Port: 2603 (2603),
Seq: 1, Ack: 438, Len: 88
Source port: http (80)
Destination port: 2603 (2603)
Source or Destination Port: 80
Source or Destination Port: 2603
TCP Segment Len: 88
Sequence number: 1 (relative sequence number)
Next sequence number: 89 (relative sequence number)
Acknowledgement number: 438 (relative ack number)
Header length: 20 bytes
Flags: 0x0018 (PSH, ACK)
0... .... = Congestion Window Reduced (CWR): Not set
.0.. .... = ECN-Echo: Not set
..0. .... = Urgent: Not set
...1 .... = Acknowledgment: Set
.... 1... = Push: Set
.... .0.. = Reset: Not set
.... ..0. = Syn: Not set
.... ...0 = Fin: Not set
Window size: 32736
Checksum: 0xec11 (correct)
SEQ/ACK analysis
TCP Analysis Flags
This frame is a (suspected) out-of-order segment
A segment before this frame was lost
Hypertext Transfer Protocol
Data (88 bytes)

0000: 00 0C F1 BC 5D 08 00 40 10 18 B8 28 08 00 45 00 ....]..@...(..E.
0010: 00 80 A6 6F 40 00 40 06 DB C8 0A 0A 01 ED AC 11 ...o@.@.........
0020: 00 38 00 50 0A 2B 88 24 F0 8B 8F 74 E7 52 50 18 .8.P.+.$...t.RP.
0030: 7F E0 EC 11 00 00 50 72 65 73 65 74 20 50 6F 73 ......Preset Pos
0040: 69 74 69 6F 6E 73 20 66 6F 72 20 61 6C 6C 20 63 itions for all c
0050: 61 6D 65 72 61 73 0A 70 72 65 73 65 74 70 6F 73 ameras.presetpos
0060: 6E 6F 31 3D 31 0A 70 72 65 73 65 74 70 6F 73 6E no1=1.presetposn
0070: 6F 32 3D 46 6C 6F 6F 72 0A 70 72 65 73 65 74 70 o2=Floor.presetp
0080: 6F 73 6E 6F 33 3D 43 65 69 6C 69 6E 67 0A osno3=Ceiling.
 

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