So, I'm trying to write a web spider for some data gathering from a
public database webserver. Anyway, in response to a POST, the webserver
returns "200 Script Results Follow" instead of "201 CREATED". While
both IE and Firefox ignore the odd header, this response kills my
HttpWebRequest with a WebException - "System.Net.Web Exception: The
server committed a protocol violation. Section=Respons eStatusLine".
Does anyone know of a workaround for this?
Thanks,
Colin
PS Code:
Code:
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Text.Reg ularExpressions ;
using System.Net;
using System.IO;
using System.Web;
namespace ConsoleApplicat ion1
{
public class InsertTest {
public static void Main() {
loHttp.Method = "POST";
byte[] lbPostBuffer = System.Text.
Encoding.GetEnc oding(1252).Get Bytes(lcPostDat a);
loHttp.ContentL ength = lbPostBuffer.Le ngth;
Stream loPostData = loHttp.GetReque stStream();
loPostData.Writ e(lbPostBuffer, 0, lbPostBuffer.Le ngth);
loPostData.Clos e();
try
{
HttpWebResponse loWebResponse =
(HttpWebRespons e)loHttp.GetRes ponse();
Encoding enc = System.Text.Enc oding.GetEncodi ng(1252);
StreamReader loResponseStrea m =
new StreamReader(lo WebResponse.Get ResponseStream( ), enc);
string lcHtml = loResponseStrea m.ReadToEnd();
loWebResponse.C lose();
loResponseStrea m.Close();
}
catch (WebException J)
{
Console.WriteLi ne("Protocol violation!\n {0}", J.ToString());
}
string adj22 = Console.ReadLin e();
}
}
}
public database webserver. Anyway, in response to a POST, the webserver
returns "200 Script Results Follow" instead of "201 CREATED". While
both IE and Firefox ignore the odd header, this response kills my
HttpWebRequest with a WebException - "System.Net.Web Exception: The
server committed a protocol violation. Section=Respons eStatusLine".
Does anyone know of a workaround for this?
Thanks,
Colin
PS Code:
Code:
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Text.Reg ularExpressions ;
using System.Net;
using System.IO;
using System.Web;
namespace ConsoleApplicat ion1
{
public class InsertTest {
public static void Main() {
loHttp.Method = "POST";
byte[] lbPostBuffer = System.Text.
Encoding.GetEnc oding(1252).Get Bytes(lcPostDat a);
loHttp.ContentL ength = lbPostBuffer.Le ngth;
Stream loPostData = loHttp.GetReque stStream();
loPostData.Writ e(lbPostBuffer, 0, lbPostBuffer.Le ngth);
loPostData.Clos e();
try
{
HttpWebResponse loWebResponse =
(HttpWebRespons e)loHttp.GetRes ponse();
Encoding enc = System.Text.Enc oding.GetEncodi ng(1252);
StreamReader loResponseStrea m =
new StreamReader(lo WebResponse.Get ResponseStream( ), enc);
string lcHtml = loResponseStrea m.ReadToEnd();
loWebResponse.C lose();
loResponseStrea m.Close();
}
catch (WebException J)
{
Console.WriteLi ne("Protocol violation!\n {0}", J.ToString());
}
string adj22 = Console.ReadLin e();
}
}
}
Comment