System.Net.Browser.PolicyBasedWebRequest.EndCallback C# (CSharp) Метод

EndCallback() приватный Метод

private EndCallback ( IAsyncResult result ) : void
result IAsyncResult
Результат void
		private void EndCallback (IAsyncResult result)
		{
			WebRequest wreq = (result.AsyncState as WebRequest);
			try {
				HttpWebResponseCore wres = (HttpWebResponseCore) wreq.EndGetResponse (result);
				//			Redirection	Error
				// Normal Request	allowed		throw
				// Policy Request	throw		ignore (no policy)
				if (IsRedirection (wres)) {
					if (IsDownloadingPolicy ()) {
						// redirection is NOT allowed for policy files
						async_result.Exception = new SecurityException ("Cannot redirect policy files");
						async_result.SetComplete ();
					} else {
						string location = wres.Headers ["Location"];
						Uri redirect = new Uri (location);
						// Silverlight does NOT redirect POST as POST to avoid cross site attacks - see DRT #866 or
						// http://blogs.msdn.com/jackgr/archive/2010/04/19/silverlight-clients-and-appfabric-access-control.aspx
						if ((String.Compare (method, "HEAD", StringComparison.OrdinalIgnoreCase) == 0) || 
							(String.Compare (method, "GET", StringComparison.OrdinalIgnoreCase) == 0)) {
							GetResponse (method, redirect, true);
						} else {
							GetResponse ("GET", redirect, false);
						}
					}
				} else if (wres.StatusCode != HttpStatusCode.OK) {
					// policy file could be missing, but then it means no policy
					if (!IsDownloadingPolicy ()) {
						async_result.Response = wres;
						async_result.Exception = NotFound (wres.ResponseUri.Scheme, wres);
						async_result.SetComplete ();
					} else {
						async_result.SetComplete ();
					}
				} else {
					wres.SetMethod (Method);
					async_result.Response = wres;
					async_result.SetComplete ();
				}
			}
			catch (Exception e) {
				async_result.Response = null;
				async_result.Exception = NotFound (wreq.RequestUri.Scheme, null);
				async_result.SetComplete ();
			}
		}