Ok, in order for generated http header not to look like proxy request I needed to tell to
connection management class that it should not connect to set up proxy:
private static DataTable GetWebpage(string requestURL, string pathname)
{
var webRequest = WebRequest.Create(requestURL);
webRequest.Method = "GET";
webRequest.Proxy = new WebProxy(proxy, proxyPort);
FieldInfo field_ServicePoint_ProxyServicePoint = (typeof(ServicePoint))
.GetField("m_ProxyServicePoint", BindingFlags.NonPublic | BindingFlags.Instance);
field_ServicePoint_ProxyServicePoint.SetValue(webRequest.ServicePoint, false);
StreamReader streamIn =
new StreamReader(webRequest.GetResponse().GetResponseStream());
string response = streamIn.ReadToEnd();
streamIn.Close();
}
I also had to enable unsafeHeaderparsing because target server violated
header format in response and I got this exception:
{"The server committed a protocol violation. Section=ResponseStatusLine"}
I found solution for programatically solving this on
msdn forum[
^]