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.WebException: The
server committed a protocol violation. Section=ResponseStatusLine".
Does anyone know of a workaround for this?
Thanks,
Colin
PS Code:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
using System.Web;
namespace ConsoleApplication1
{
public class InsertTest {
public static void Main() {
loHttp.Method = "POST";
byte[] lbPostBuffer = System.Text.
Encoding.GetEncoding(1252).GetBytes(lcPostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer, 0, lbPostBuffer.Length);
loPostData.Close();
try
{
HttpWebResponse loWebResponse =
(HttpWebResponse)loHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream =
new StreamReader(loWebResponse.GetResponseStream(), enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
}
catch (WebException J)
{
Console.WriteLine("Protocol violation!\n {0}", J.ToString());
}
string adj22 = Console.ReadLine();
}
}
}