Fix webResponse being after Dispose.

This commit is contained in:
2025-03-27 23:31:24 -04:00
parent 860de51b77
commit 0140e63a37

View File

@@ -126,7 +126,6 @@ namespace MarketData.Integration
if(charCount<=0)break;
memoryStream.Write(buffer,0,charCount);
}
webResponse.Close();
memoryStream.Flush();
return new HttpNetResponse(memoryStream,strRequest,webResponse,true);
}
@@ -139,7 +138,12 @@ namespace MarketData.Integration
return new HttpNetResponse(webResponse,strRequest,false,exception.Message);
}
finally
{
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestStreamZIP[LEAVE]");
}
}
@@ -169,7 +173,6 @@ namespace MarketData.Integration
if(charCount<=0)break;
memoryStream.Write(buffer,0,charCount);
}
webResponse.Close();
memoryStream.Flush();
return new HttpNetResponse(memoryStream,strRequest,webResponse,true);
}
@@ -179,6 +182,11 @@ namespace MarketData.Integration
}
catch (Exception exception)
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
return new HttpNetResponse(webResponse,strRequest,false,exception.Message);
}
finally
@@ -239,7 +247,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch (WebException webException)
@@ -252,6 +259,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestStreamCSV[LEAVE]");
}
}
@@ -284,7 +296,6 @@ namespace MarketData.Integration
if (0 >= charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch (WebException webException)
@@ -297,6 +308,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncoding[LEAVE]");
}
}
@@ -329,7 +345,6 @@ namespace MarketData.Integration
if(0>=charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer,0,charCount));
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch(WebException webException)
@@ -342,6 +357,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncoding[LEAVE]");
}
}
@@ -372,7 +392,6 @@ namespace MarketData.Integration
if (0 == charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch (WebException webException)
@@ -385,6 +404,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestCSV[LEAVE]");
}
}
@@ -412,7 +436,6 @@ namespace MarketData.Integration
if (0 == charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch (WebException webException)
@@ -425,6 +448,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV2[LEAVE]");
}
}
@@ -490,7 +518,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch (WebException webException)
@@ -512,6 +539,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV3[LEAVE]");
}
}
@@ -583,7 +615,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer,0,charCount));
}
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch(WebException webException)
@@ -605,6 +636,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV3A[LEAVE]");
}
}
@@ -669,7 +705,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer,0,charCount));
}
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch(WebException webException)
@@ -691,6 +726,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV3B[LEAVE]");
}
}
@@ -763,7 +803,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer,0,charCount));
}
}
webResponse.Close();
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,true);
}
catch(WebException webException)
@@ -785,6 +824,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV3C[LEAVE]");
}
}
@@ -819,7 +863,6 @@ namespace MarketData.Integration
if (0 == charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,webResponse.Cookies,true);
@@ -834,6 +877,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV4[LEAVE]");
}
}
@@ -878,7 +926,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer,0,charCount));
}
}
webResponse.Close();
ServicePointManager.Expect100Continue=expect100Condition;
ServicePointManager.SecurityProtocol=securityProtocolType;
return new HttpNetResponse(sb.ToString(),strRequest,webResponse,webResponse.Cookies,true);
@@ -893,6 +940,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE,"GetRequestNoEncodingV4[LEAVE]");
}
}
@@ -927,7 +979,6 @@ namespace MarketData.Integration
if (0 == charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return new HttpNetResponse(sb.ToString(), strRequest, webResponse, webResponse.Cookies, true);
@@ -942,6 +993,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingV5[LEAVE]");
}
}
@@ -981,8 +1037,6 @@ namespace MarketData.Integration
if(index>=userAgents.Length) index=userAgents.Length-1;
String userAgent=userAgents[index];
webRequest.UserAgent=userAgent;
webResponse = (HttpWebResponse)webRequest.GetResponse();
Stream responseStream = webResponse.GetResponseStream();
while (true)
@@ -991,7 +1045,6 @@ namespace MarketData.Integration
if (0 == charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return new HttpNetResponse(sb.ToString(), strRequest, webResponse, webResponse.Cookies, true);
@@ -1006,6 +1059,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingV5A[LEAVE]");
}
}
@@ -1042,7 +1100,6 @@ namespace MarketData.Integration
if (0 == charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return new HttpNetResponse(sb.ToString(), strRequest, webResponse, webResponse.Cookies, true);
@@ -1057,6 +1114,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingV5B[LEAVE]");
}
}
@@ -1097,7 +1159,6 @@ namespace MarketData.Integration
if(null!=cookieCollection)webRequest.CookieContainer.Add(cookieCollection);
webResponse = (HttpWebResponse)webRequest.GetResponse();
HttpNetResponse httpNetResponse = ProcessWebResponse(strRequest, webResponse);
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return httpNetResponse;
@@ -1112,6 +1173,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingV5C[LEAVE]");
}
}
@@ -1154,7 +1220,6 @@ namespace MarketData.Integration
HttpNetResponse httpNetResponse = ProcessWebResponse(strRequest, webResponse);
httpNetResponse.CookieCollection = new CookieCollection();
httpNetResponse.CookieCollection.Add(webResponse.Cookies);
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return httpNetResponse;
@@ -1169,6 +1234,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingV5C[LEAVE]");
}
}
@@ -1242,7 +1312,6 @@ namespace MarketData.Integration
if (0 == charCount) break;
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return new HttpNetResponse(sb.ToString(), strRequest, webResponse, webResponse.Cookies, true);
@@ -1257,6 +1326,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingV6[LEAVE]");
}
}
@@ -1310,8 +1384,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
}
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return new HttpNetResponse(sb.ToString(), strRequest, webResponse, webResponse.Cookies, true);
@@ -1326,6 +1398,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingV7[LEAVE]");
}
}
@@ -1387,8 +1464,6 @@ namespace MarketData.Integration
sb.Append(Encoding.ASCII.GetString(buffer, 0, charCount));
}
}
webResponse.Close();
ServicePointManager.Expect100Continue = expect100Condition;
ServicePointManager.SecurityProtocol = securityProtocolType;
return new HttpNetResponse(sb.ToString(), strRequest, webResponse, webResponse.Cookies, true);
@@ -1403,6 +1478,11 @@ namespace MarketData.Integration
}
finally
{
if(null!=webResponse)
{
webResponse.Close();
webResponse.Dispose();
}
MDTrace.WriteLine(LogLevel.VERBOSE, "GetRequestNoEncodingMStar[LEAVE]");
}
}