Merge MKDT_0002
This commit is contained in:
@@ -406,24 +406,24 @@ namespace MarketData.Integration
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpNetResponse GetRequestCSV(String strRequest,String referer)
|
||||
public static HttpNetResponse GetRequestNoEncodingV2(String strRequest,WebProxy webProxy=null)
|
||||
{
|
||||
HttpWebResponse webResponse=null;
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE,String.Format("GetRequestCSV[ENTER]{0}",strRequest));
|
||||
ServicePointManager.Expect100Continue = true;
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE,String.Format("GetRequestNoEncoding[ENTER]{0}",strRequest));
|
||||
int charCount = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
StringBuilder sb = new StringBuilder();
|
||||
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(strRequest));
|
||||
if(null!=webProxy)webRequest.Proxy=webProxy;
|
||||
webRequest.Timeout = REQUEST_TIMEOUT;
|
||||
webRequest.Accept="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
||||
webRequest.Accept = "text/html, text/csv";
|
||||
webRequest.ContentType="text/csv; charset=utf-8";
|
||||
webRequest.Headers.Add("Accept-Encoding: identity"); // "gzip, deflate"
|
||||
webRequest.Headers.Add("Accept-Language: en-US,en;q=0.5");
|
||||
webRequest.Headers.Add("Upgrade-Insecure-Requests: 1");
|
||||
webRequest.UserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0";
|
||||
webRequest.Referer=referer;
|
||||
webRequest.Headers.Add("Accept-Encoding: None");
|
||||
webRequest.Headers.Add("Accept-Language: en-US");
|
||||
webRequest.UserAgent = "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36";
|
||||
webRequest.KeepAlive = true;
|
||||
try{webResponse = (HttpWebResponse)webRequest.GetResponse();}
|
||||
catch(WebException webException)
|
||||
@@ -439,7 +439,7 @@ namespace MarketData.Integration
|
||||
while (true)
|
||||
{
|
||||
charCount = responseStream.Read(buffer, 0, buffer.Length);
|
||||
if (0 == charCount) break;
|
||||
if (0 >= charCount) break;
|
||||
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
|
||||
}
|
||||
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
|
||||
@@ -459,7 +459,64 @@ namespace MarketData.Integration
|
||||
webResponse.Close();
|
||||
webResponse.Dispose();
|
||||
}
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestCSV[LEAVE]");
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncoding[LEAVE]");
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpNetResponse GetRequestCSV(String strRequest, String referer)
|
||||
{
|
||||
HttpWebResponse webResponse = null;
|
||||
try
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE, String.Format("GetRequestCSV[ENTER]{0}", strRequest));
|
||||
int charCount = 0;
|
||||
byte[] buffer = new byte[8192];
|
||||
StringBuilder sb = new StringBuilder();
|
||||
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(strRequest));
|
||||
webRequest.Timeout = REQUEST_TIMEOUT;
|
||||
webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
||||
webRequest.ContentType = "text/csv; charset=utf-8";
|
||||
webRequest.Headers.Add("Accept-Encoding: identity"); // "gzip, deflate"
|
||||
webRequest.Headers.Add("Accept-Language: en-US,en;q=0.5");
|
||||
webRequest.Headers.Add("Upgrade-Insecure-Requests: 1");
|
||||
webRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0";
|
||||
webRequest.Referer = referer;
|
||||
webRequest.KeepAlive = true;
|
||||
try { webResponse = (HttpWebResponse)webRequest.GetResponse(); }
|
||||
catch (WebException webException)
|
||||
{
|
||||
if (IsMovedException(webException))
|
||||
{
|
||||
webRequest = Redirect(webRequest, webException);
|
||||
webResponse = (HttpWebResponse)webRequest.GetResponse();
|
||||
}
|
||||
else throw;
|
||||
}
|
||||
Stream responseStream = webResponse.GetResponseStream();
|
||||
while (true)
|
||||
{
|
||||
charCount = responseStream.Read(buffer, 0, buffer.Length);
|
||||
if (0 == charCount) break;
|
||||
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
|
||||
}
|
||||
return new HttpNetResponse(sb.ToString(), strRequest, webResponse, true);
|
||||
}
|
||||
catch (WebException webException)
|
||||
{
|
||||
return new HttpNetResponse((HttpWebResponse)webException.Response, strRequest, false, webException.Message);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
return new HttpNetResponse(webResponse, strRequest, false, exception.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != webResponse)
|
||||
{
|
||||
webResponse.Close();
|
||||
webResponse.Dispose();
|
||||
}
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestCSV[LEAVE]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,9 +532,10 @@ namespace MarketData.Integration
|
||||
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(strRequest));
|
||||
webRequest.Timeout = REQUEST_TIMEOUT;
|
||||
webRequest.Headers.Add("Accept-Language: en-US,en;q=0.5");
|
||||
webRequest.Headers.Add("Accept-Encoding: None");
|
||||
webRequest.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0";
|
||||
webRequest.Accept = "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
|
||||
webRequest.ContentType = "text/csv; charset=utf-8";
|
||||
webRequest.Headers.Add("Accept-Encoding: gzip, deflate, br, zstd");
|
||||
webRequest.UserAgent = "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36";
|
||||
webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
||||
webRequest.KeepAlive = true;
|
||||
try{webResponse = (HttpWebResponse)webRequest.GetResponse();}
|
||||
catch(WebException webException)
|
||||
|
||||
Reference in New Issue
Block a user