Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FinishRequestStage()

RequestStage System.Net.FtpWebRequest.FinishRequestStage ( RequestStage stage)
inlineprivate

Definition at line 1219 of file FtpWebRequest.cs.

1220 {
1221 if (System.Net.NetEventSource.Log.IsEnabled())
1222 {
1223 System.Net.NetEventSource.Info(this, $"state:{stage}", "FinishRequestStage");
1224 }
1225 if (_exception != null)
1226 {
1227 stage = RequestStage.ReleaseConnection;
1228 }
1229 RequestStage requestStage;
1230 LazyAsyncResult writeAsyncResult;
1231 LazyAsyncResult readAsyncResult;
1232 FtpControlStream connection;
1233 lock (_syncObject)
1234 {
1235 requestStage = _requestStage;
1236 if (stage == RequestStage.CheckForError)
1237 {
1238 return requestStage;
1239 }
1240 if (requestStage == RequestStage.ReleaseConnection && stage == RequestStage.ReleaseConnection)
1241 {
1242 return RequestStage.ReleaseConnection;
1243 }
1244 if (stage > requestStage)
1245 {
1246 _requestStage = stage;
1247 }
1248 if (stage <= RequestStage.RequestStarted)
1249 {
1250 return requestStage;
1251 }
1252 writeAsyncResult = _writeAsyncResult;
1253 readAsyncResult = _readAsyncResult;
1254 connection = _connection;
1255 if (stage == RequestStage.ReleaseConnection)
1256 {
1257 if (_exception == null && !_aborted && requestStage != RequestStage.ReadReady && _methodInfo.IsDownload && !_ftpWebResponse.IsFromCache)
1258 {
1259 return requestStage;
1260 }
1261 _connection = null;
1262 }
1263 }
1264 try
1265 {
1266 if ((stage == RequestStage.ReleaseConnection || requestStage == RequestStage.ReleaseConnection) && connection != null)
1267 {
1268 try
1269 {
1270 if (_exception != null)
1271 {
1272 connection.Abort(_exception);
1273 }
1274 }
1275 finally
1276 {
1277 if (System.Net.NetEventSource.Log.IsEnabled())
1278 {
1279 System.Net.NetEventSource.Info(this, $"Releasing connection: {connection}", "FinishRequestStage");
1280 }
1281 connection.CloseSocket();
1282 if (_async && _requestCompleteAsyncResult != null)
1283 {
1285 }
1286 }
1287 }
1288 return requestStage;
1289 }
1290 finally
1291 {
1292 try
1293 {
1294 if (stage >= RequestStage.WriteReady)
1295 {
1297 {
1298 if (_stream != null)
1299 {
1300 _stream.Close();
1301 }
1302 }
1303 else if (writeAsyncResult != null && !writeAsyncResult.InternalPeekCompleted)
1304 {
1305 writeAsyncResult.InvokeCallback();
1306 }
1307 }
1308 }
1309 finally
1310 {
1311 if (stage >= RequestStage.ReadReady && readAsyncResult != null && !readAsyncResult.InternalPeekCompleted)
1312 {
1313 readAsyncResult.InvokeCallback();
1314 }
1315 }
1316 }
1317 }
virtual void Close()
Definition Stream.cs:644
virtual void Abort(Exception e)
LazyAsyncResult _readAsyncResult
FtpControlStream _connection
FtpWebResponse _ftpWebResponse
ContextAwareResult _writeAsyncResult
LazyAsyncResult _requestCompleteAsyncResult
void InvokeCallback(object result)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
virtual bool IsFromCache

References System.Net.CommandStream.Abort(), System.IO.Stream.Close(), System.Net.NetworkStreamWrapper.CloseSocket(), System.Net.NetEventSource.Info(), System.Net.LazyAsyncResult.InternalPeekCompleted, System.Net.LazyAsyncResult.InvokeCallback(), System.Net.FtpMethodInfo.IsDownload, System.Net.WebResponse.IsFromCache, System.Net.FtpMethodInfo.IsUpload, and System.Net.NetEventSource.Log.

Referenced by System.Net.FtpWebRequest.BeginGetRequestStream(), System.Net.FtpWebRequest.BeginGetResponse(), System.Net.FtpWebRequest.GetRequestStream(), and System.Net.FtpWebRequest.GetResponse().