Refactorings.
This commit is contained in:
@@ -498,7 +498,10 @@ namespace MarketData.Integration
|
||||
}
|
||||
catch (WebException webException)
|
||||
{
|
||||
if(webException.Message.Contains("(404) Not Found"))return new HttpNetResponse(webResponse,strRequest,false,null==lastWebException?"":lastWebException.Message);
|
||||
if(webException.Message.Contains("(404) Not Found"))
|
||||
{
|
||||
return new HttpNetResponse((HttpWebResponse)webException.Response, strRequest, false, webException.Message);
|
||||
}
|
||||
lastWebException=webException;
|
||||
Thread.Sleep(TIMEOUT_BETWEEN_RETRIES);
|
||||
}
|
||||
@@ -588,7 +591,10 @@ namespace MarketData.Integration
|
||||
}
|
||||
catch(WebException webException)
|
||||
{
|
||||
if(webException.Message.Contains("(404) Not Found")) return new HttpNetResponse(webResponse,strRequest,false,null==lastWebException?"":lastWebException.Message);
|
||||
if(webException.Message.Contains("(404) Not Found"))
|
||||
{
|
||||
return new HttpNetResponse((HttpWebResponse)webException.Response, strRequest, false, webException.Message);
|
||||
}
|
||||
lastWebException=webException;
|
||||
Thread.Sleep(TIMEOUT_BETWEEN_RETRIES);
|
||||
}
|
||||
@@ -671,7 +677,10 @@ namespace MarketData.Integration
|
||||
}
|
||||
catch(WebException webException)
|
||||
{
|
||||
if(webException.Message.Contains("(404) Not Found")) return new HttpNetResponse(webResponse,strRequest,false,null==lastWebException?"":lastWebException.Message);
|
||||
if(webException.Message.Contains("(404) Not Found"))
|
||||
{
|
||||
return new HttpNetResponse((HttpWebResponse)webException.Response, strRequest, false, webException.Message);
|
||||
}
|
||||
lastWebException=webException;
|
||||
Thread.Sleep(TIMEOUT_BETWEEN_RETRIES);
|
||||
}
|
||||
@@ -762,7 +771,10 @@ namespace MarketData.Integration
|
||||
}
|
||||
catch(WebException webException)
|
||||
{
|
||||
if(webException.Message.Contains("(404) Not Found")) return new HttpNetResponse(webResponse,strRequest,false,null==lastWebException?"":lastWebException.Message);
|
||||
if(webException.Message.Contains("(404) Not Found"))
|
||||
{
|
||||
return new HttpNetResponse((HttpWebResponse)webException.Response, strRequest, false, webException.Message);
|
||||
}
|
||||
lastWebException=webException;
|
||||
Thread.Sleep(TIMEOUT_BETWEEN_RETRIES);
|
||||
}
|
||||
@@ -776,7 +788,7 @@ namespace MarketData.Integration
|
||||
}
|
||||
finally
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV3A[LEAVE]");
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV3C[LEAVE]");
|
||||
}
|
||||
}
|
||||
public static HttpNetResponse GetRequestNoEncodingV4(String strRequest,CookieCollection cookieCollection=null,WebProxy webProxy=null)
|
||||
@@ -1192,6 +1204,13 @@ namespace MarketData.Integration
|
||||
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingMStar[LEAVE]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the proxy for the specified service or null if it is not congfigured to use the proxy
|
||||
/// </summary>
|
||||
///<param name="serviceName">The service name</param>
|
||||
public static WebProxy GetProxy(String serviceName)
|
||||
{
|
||||
try
|
||||
@@ -1224,6 +1243,32 @@ namespace MarketData.Integration
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("GetProxy: Exception:{0}",exception.ToString()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the proxy. This is only to be used as part of unit tests to test out the TOR Proxy. User code should use the GetProxy(serviceName) variation
|
||||
/// </summary>
|
||||
public static WebProxy GetProxy()
|
||||
{
|
||||
String proxyAddress=ConfigurationManager.AppSettings["proxy_address"];
|
||||
String[] addressParts=proxyAddress.Split(':');
|
||||
SocketControl socketControl=null;
|
||||
try
|
||||
{
|
||||
socketControl=new SocketControl(addressParts[1].Replace("//",null),int.Parse(addressParts[2]));
|
||||
if(!socketControl.IsConnected())throw new Exception("Unreachable destination "+proxyAddress);
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("****** ERROR: CANNOT REACH PROXY. {0} {1} ",proxyAddress,exception.ToString()));
|
||||
return null;
|
||||
}
|
||||
socketControl.Close();
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("USING PROXY:{0} ",proxyAddress));
|
||||
Uri newUri=new Uri(proxyAddress);
|
||||
WebProxy proxy=new WebProxy();
|
||||
proxy.Address=newUri;
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user