public override NSUrlRequest WillSendRequest( NSUrlConnection connection, NSUrlRequest request, NSUrlResponse response) { NSMutableUrlRequest mutableRequest = (NSMutableUrlRequest)request.MutableCopy(); if (response != null) { RemoveProperty("ADURLProtocol", mutableRequest); _client.Redirected(_handler, mutableRequest, response); connection.Cancel(); if (!request.Headers.ContainsKey(new NSString("x-ms-PkeyAuth"))) { mutableRequest[BrokerConstants.ChallengeHeaderKey] = BrokerConstants.ChallengeHeaderValue; } return(mutableRequest); } if (!request.Headers.ContainsKey(new NSString(BrokerConstants.ChallengeHeaderKey))) { mutableRequest[BrokerConstants.ChallengeHeaderKey] = BrokerConstants.ChallengeHeaderValue; } return(mutableRequest); }
public override void FinishedLoading(NSUrlConnection connection) { Application.Done(); var ms = new MemoryStream(result); ad.RenderStream(ms); }
void useUrlConnection(NSMutableUrlRequest request) { var connection = new NSUrlConnection(request, this); UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; connection.Start(); }
private async Task <HttpResponseMessage> Send(Uri requestUri, string content, string method, IDictionary <String, String> headers) { if (null == Certificate) { throw new ApplicationException("No certificate has been provided. The request is cancelled."); } _taskSource = new TaskCompletionSource <HttpResponseMessage>(); var request = new NSMutableUrlRequest(new NSUrl(requestUri.ToString()), NSUrlRequestCachePolicy.ReloadIgnoringCacheData, TimeOut) { HttpMethod = method, Body = NSData.FromString(content) }; if (null != headers) { foreach (var header in headers) { request[header.Key] = new NSString(header.Value); } } var conn = NSUrlConnection.FromRequest(request, this); return(await _taskSource.Task); }
public virtual void WillSendRequestForAuthenticationChallenge(NSUrlConnection connection, NSUrlAuthenticationChallenge challenge) { if (challenge.PreviousFailureCount == 2) { //TODO: update cred } else if (challenge.PreviousFailureCount > 2) { //display alert XamarinAlertController.showAlertViewForController(this, SDKErrorLoginFailedTitle, SDKErrorLoginFailedMessage); } else { //handle challenges if (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodServerTrust") { var cred = new NSUrlCredential(challenge.ProtectionSpace.ServerSecTrust); challenge.Sender.UseCredential(cred, challenge); } else if ((challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodHTTPBasic") || (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodNTLM") || (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodClientCertificate")) { handleChallengeForConnection(challenge); } else { Console.WriteLine("AWXamarin Authentication challenge is not supported by the SDK"); XamarinAlertController.showAlertViewForController(this, SDKErrorAuthNotSupportedTitle, SDKErrorAuthNotSupportedMessage); } } }
public override void ReceivedResponse(NSUrlConnection connection, NSUrlResponse response) { if (response is NSHttpUrlResponse http_response) { status_code = (int)http_response.StatusCode; } }
public override void ReceivedData(NSUrlConnection connection, NSData data) { if (data != null) { _ResponseBuilder.Append(data.ToString()); } }
public Response <UIImage> Load(Uri uri, bool localCacheOnly) { NSUrl url = NSUrl.FromString(uri.AbsoluteUri); var cachePolicy = localCacheOnly ? NSUrlRequestCachePolicy.ReturnCacheDataDoNotLoad : NSUrlRequestCachePolicy.ReturnCacheDataElseLoad; var request = new NSUrlRequest(url, cachePolicy, 20); NSCachedUrlResponse cachedResponse = NSUrlCache.SharedCache.CachedResponseForRequest(request); if (cachedResponse != null) { return(new Response <UIImage>(cachedResponse.Data.AsStream(), true, cachedResponse.Data.Length)); } NSUrlResponse response; NSError error; NSData data = NSUrlConnection.SendSynchronousRequest(request, out response, out error); if (error != null || data == null) { return(null); } cachedResponse = new NSCachedUrlResponse(response, data, null, NSUrlCacheStoragePolicy.Allowed); NSUrlCache.SharedCache.StoreCachedResponse(cachedResponse, request); return(new Response <UIImage>(data.AsStream(), false, data.Length)); }
// Collect all the data public override void ReceivedData(NSUrlConnection connection, NSData data) { byte [] nb = new byte [result.Length + data.Length]; result.CopyTo(nb, 0); Marshal.Copy(data.Bytes, nb, result.Length, (int)data.Length); result = nb; }
public override void FinishedLoading(NSUrlConnection connection) { if (iCell != null) { UIImage temp = new UIImage(iData); if (temp.CGImage.Width > 0 && temp.CGImage.Height > 0) { UIImage image = ImageToFitSize(temp, new SizeF(107.0f, 107.0f)); iData = null; ArtworkCacheInstance.Instance.AddImage(iUri, image); if (iCell.iUri == iUri) { iCell.Image = image; } } else { iData = null; ArtworkCacheInstance.Instance.AddImage(iUri, null); if (iCell.iUri == iUri) { iCell.Image = KinskyTouch.Properties.ResourceManager.AlbumError; } } } }
public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) { if (null != _controller && _controller.Url != null) { if (request.Url.Equals(_controller.Url)) { return(true); } } if (_controller != null) { _controller.Url = request.Url; var scheme = _controller.Url.Scheme; if (scheme.Equals("acs")) { var b = new StringBuilder(Uri.UnescapeDataString(request.Url.ToString())); b.Replace("acs://settoken?token=", string.Empty); RequestSecurityTokenResponseStore.Instance.RequestSecurityTokenResponse = RequestSecurityTokenResponse.FromJSON(b.ToString()); _controller.NavigationController.PopToRootViewController(true); } } NSUrlConnection.FromRequest(request, _urlDelegate); return(false); }
/// <summary> /// /// </summary> /// <param name="aObject"> /// A <see cref="Upnp.upnpObject"/> /// </param> public void SetItem(Upnp.upnpObject aObject) { if (iConnection != null) { iConnection.Cancel(); iConnection = null; } if (aObject != null) { Uri uri = DidlLiteAdapter.ArtworkUri(aObject); if (uri != null) { NSUrl url = new NSUrl(iUriConverter.Convert(uri.AbsoluteUri)); NSUrlRequest request = new NSUrlRequest(url); iConnection = new NSUrlConnection(request, new Delegate(this), true); } else { SetImage(KinskyTouch.Properties.ResourceManager.Loading); } } else { SetImage(KinskyTouch.Properties.ResourceManager.Loading); } }
public override void StartLoading() { if (!UseCache) { var connectionRequest = (NSMutableUrlRequest)Request.MutableCopy; // we need to mark this request with our header so we know not to handle it in +[NSURLProtocol canInitWithRequest:]. connectionRequest.SetValueForKey("", MtRnCachingUrlHeader); var connection = NSUrlConnection.FromRequest(connectionRequest, this); Connection = connection; } else { var cache = NSKeyedUnarchiver.UnarchiveFile(CachePathForRequest(this.Request)) as MtRnCachedData; if (cache != null) { var data = cache.Data; var response = cache.Response; var redirectRequest = cache.RedirectRequest; if (redirectRequest != null) { this.Client.Redirected(this, redirectRequest, response); } else { Client.ReceivedResponse(this, response, NSUrlCacheStoragePolicy.NotAllowed); Client.DataLoaded(this, data); Client.FinishedLoading(this); } } else { this.Client.FailedWithError(NSError.FromDomain("TODO", NSUrlError.CannotConnectToHost)); } } }
public override void ReceivedData(NSUrlConnection connection, NSData data) { if (result == null) { result = new byte[data.Length]; Marshal.Copy(data.Bytes, result, 0, (int)data.Length); } else if (written + (int)data.Length > result.Length) { byte[] nb = new byte [result.Length + (int)data.Length]; result.CopyTo(nb, 0); Marshal.Copy(data.Bytes, nb, result.Length, (int)data.Length); result = nb; } else { Marshal.Copy(data.Bytes, result, written, (int)data.Length); } written += (int)data.Length; if (nr.AbortRequested) { connection.Cancel(); return; } nr.TriggerUpdate(); }
public override void FinishedLoading (NSUrlConnection connection) { _view.indicatorView.StopAnimating(); UIImage downloadedImage = UIImage.LoadFromData(_view.imageData); _view.imageData = null; _view.Image = downloadedImage; }
public override void ReceivedData(NSUrlConnection connection, NSData data) { if (audioFileStream.ParseBytes((int)data.Length, data.Bytes, false) != AudioFileStreamStatus.Ok) { throw new ApplicationException(); } }
public override void ViewDidLoad() { base.ViewDidLoad(); fecthResultsControllerDelegate = new FecthResultsControllerDelegate() { TableView = TableView }; var feedURLString = new NSString("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson"); var earthquakeURLRequest = NSUrlRequest.FromUrl(new NSUrl(feedURLString)); NSUrlConnection.SendAsynchronousRequest(earthquakeURLRequest, NSOperationQueue.MainQueue, RequestCompletionHandler); UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; parseQueue = new NSOperationQueue(); parseQueue.AddObserver(this, new NSString("operationCount"), NSKeyValueObservingOptions.New, IntPtr.Zero); //HACK: Parsed strings to NSString NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("EarthquakesError:"), (NSString)APLParseOperation.EarthquakesErrorNotificationName, null); NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("LocaleChanged:"), (NSString)NSLocale.CurrentLocaleDidChangeNotification, null); var spinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White); spinner.StartAnimating(); activityIndicator = new UIBarButtonItem(spinner); NavigationItem.RightBarButtonItem = activityIndicator; }
// Collect all the data public override void ReceivedData (NSUrlConnection connection, NSData data) { byte [] nb = new byte [result.Length + data.Length]; result.CopyTo (nb, 0); Marshal.Copy (data.Bytes, nb, result.Length, (int) data.Length); result = nb; }
public void UploadStream (string url, long content_length, Action completed) { if (url == null) throw new ArgumentNullException ("url"); AddHeader ("Expect", "100-continue"); AddHeader ("Content-Type", "application/octet-stream"); AddHeader ("Content-Length", content_length.ToString ()); InvokeOnMainThread (delegate { try { request = CreateNativePostRequest (url, content_length); } catch (Exception e) { Console.WriteLine ("Exception uploading stream"); Console.WriteLine (e); completed (); return; } url_connection = NSUrlConnection.FromRequest (request, new NativeUrlDelegate ((body) => { completed (); request.Dispose (); }, (reason) => { Console.WriteLine ("upload failed: " + reason); completed (); })); }); }
private bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) { if (Url != null && request.Url.Equals(Url)) { return(true); } Url = request.Url; if (Url.Scheme.Equals("acs")) { var b = new StringBuilder(Uri.UnescapeDataString(request.Url.ToString())); b.Replace("acs://settoken?token=", string.Empty); var token = RequestSecurityTokenResponse.FromJSON(b.ToString()); _messageHub.Publish(new RequestTokenMessage(this) { TokenResponse = token }); DismissViewController(true, null); } NSUrlConnection.FromRequest(request, new LoginConnectionDelegate(this)); return(false); }
public override void FailedWithError(NSUrlConnection connection, NSError error) { this.Client.FailedWithError(this, error); this.Connection = null; this.Data = null; this.Response = null; }
public void UploadStream(string url, long content_length, Action completed) { if (url == null) { throw new ArgumentNullException("url"); } AddHeader("Expect", "100-continue"); AddHeader("Content-Type", "application/octet-stream"); AddHeader("Content-Length", content_length.ToString()); InvokeOnMainThread(delegate { try { request = CreateNativePostRequest(url, content_length); } catch (Exception e) { Console.WriteLine("Exception uploading stream"); Console.WriteLine(e); completed(); return; } url_connection = NSUrlConnection.FromRequest(request, new NativeUrlDelegate((body) => { completed(); request.Dispose(); }, (reason) => { Console.WriteLine("upload failed: " + reason); completed(); })); }); }
// NSURLConnection delegates (generally we pass these on to our client) public override NSUrlRequest WillSendRequest(NSUrlConnection connection, NSUrlRequest request, NSUrlResponse response) { // Thanks to Nick Dowell https://gist.github.com/1885821 if (response != null) { var redirectableRequest = Request.MutableCopy as NSMutableUrlRequest; // We need to remove our header so we know to handle this request and cache it. // There are 3 requests in flight: the outside request, which we handled, the internal request, // which we marked with our header, and the redirectableRequest, which we're modifying here. // The redirectable request will cause a new outside request from the NSURLProtocolClient, which // must not be marked with our header. redirectableRequest.SetValueForKey(null, MtRnCachingUrlHeader); var cachePath = CachePathForRequest(this.Request); var cache = new MtRnCachedData(); cache.Response = response; cache.Data = this.Data; cache.RedirectRequest = redirectableRequest; NSKeyedArchiver.ArchiveRootObjectToFile(cache, cachePath); this.Client.Redirected(this, redirectableRequest, response); return(redirectableRequest); } else { return(request); } }
public override void FailedWithError(NSUrlConnection connection, NSError error) { if (AsyncDownloadFailed != null) { AsyncDownloadFailed(this, new AsyncDownloadFailed_EventArgs(error)); } }
protected override void Dispose(bool disposing) { if (url_connection != null) { url_connection.Dispose(); url_connection = null; } if (request != null) { if (request.BodyStream != null) { request.BodyStream = null; } request.Dispose(); request = null; } if (random_input_stream != null) { random_input_stream.Dispose(); random_input_stream = null; } base.Dispose(disposing); }
public override void FailedWithError(NSUrlConnection connection, NSError error) { if (failure_callback != null) { failure_callback(error.LocalizedDescription); } }
public override void ReceivedData (NSUrlConnection connection, NSData data) { if (_view.imageData==null) _view.imageData = new NSMutableData(); _view.imageData.AppendData(data); }
public override void FinishedLoading(NSUrlConnection connection) { cell.indicatorView.StopAnimating(); var downloadedImage = UIImage.LoadFromData(cell.imageData); cell.imageData = null; cell.ImageView.Image = downloadedImage; }
private void WillSendRequestForAuthenticationChallenge(NSUrlConnection connection, NSUrlAuthenticationChallenge challenge) { if (challenge.ProtectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodServerTrust) { var trust = challenge.ProtectionSpace.ServerSecTrust; var result = trust.Evaluate(); bool trustedCertificate = result == SecTrustResult.Proceed || result == SecTrustResult.Unspecified; if (!trustedCertificate && trust.Count != 0) { var originalCertificate = trust[0].ToX509Certificate2(); var x509Certificate = new Certificate(challenge.ProtectionSpace.Host, originalCertificate); trustedCertificate = _renderer.Element.ShouldTrustUnknownCertificate(x509Certificate); } if (trustedCertificate) { challenge.Sender.UseCredential(new NSUrlCredential(trust), challenge); } else { Console.WriteLine("Rejecting request"); challenge.Sender.CancelAuthenticationChallenge(challenge); SendFailedNavigation(); return; } } challenge.Sender.PerformDefaultHandling(challenge); }
public override void FinishedLoading(NSUrlConnection connection) { if (AsyncDownloadComplete != null) { AsyncDownloadComplete(this, new AsyncDownloadComplete_EventArgs()); } }
public override void FinishedLoading (NSUrlConnection connection) { BeginInvokeOnMainThread ( ()=> { hud.CustomView = new UIImageView (UIImage.FromBundle ("37x-Checkmark.png")); }); hud.Mode = MBProgressHUDMode.CustomView; hud.Hide(true, 2); }
private void ReceivedResponse(NSUrlConnection connection, NSUrlResponse response) { connection.Cancel(); if (_request != null) { _renderer.LoadRequest(_request); } }
public override void ReceivedData(NSUrlConnection connection, NSData data) { if (_data == null) { _data = new NSMutableData(); } _data.AppendData(data); }
void DownloadUsingNSUrlRequest (object sender, EventArgs e) { var downloadedDelegate = new CustomDelegate(this); var req = new NSUrlRequest(new NSUrl("http://ch3cooh.hatenablog.jp/")); NSUrlConnection connection = new NSUrlConnection(req, downloadedDelegate); connection.Start(); }
public override void FinishedLoading(NSUrlConnection connection) { BeginInvokeOnMainThread(() => { hud.CustomView = new UIImageView(UIImage.FromBundle("37x-Checkmark.png")); }); hud.Mode = MBProgressHUDMode.CustomView; hud.Hide(true, 2); }
static bool SendRequest(NSUrlRequest request) { NSUrlResponse response = null; NSError error = null; NSData data = NSUrlConnection.SendSynchronousRequest(request, out response, out error); return(true); }
public override void FinishedLoading(NSUrlConnection connection) { _view.indicatorView.StopAnimating(); UIImage downloadedImage = UIImage.LoadFromData(_view.imageData); _view.imageData = null; _view.Image = downloadedImage; }
public override void ReceivedData(NSUrlConnection connection, NSData data) { if (this.tempData == null) { this.tempData = new NSMutableData(); } this.tempData.AppendData(data); }
public override void FinishedLoading(NSUrlConnection connection) { if (_statusCode != 200) { _failureCallback(string.Format("Did not receive a 200 HTTP status code, received '{0}'", _statusCode), _statusCode); return; } _successCallback(_data, _statusCode); }
public override void StartLoading() { if (this.Request == null) { return; } NSMutableUrlRequest mutableRequest = (NSMutableUrlRequest) this.Request.MutableCopy(); SetProperty(new NSString("YES"), "MsalCustomUrlProtocol", mutableRequest); this.connection = new NSUrlConnection(mutableRequest, new MsalCustomConnectionDelegate(this), true); }
public override void ReceivedResponse(NSUrlConnection connection, NSUrlResponse response) { var httpResponse = response as NSHttpUrlResponse; Resp = httpResponse; if (httpResponse == null) { _statusCode = -1; return; } _statusCode = httpResponse.StatusCode; }
/// <summary> /// Connection has successfully downloaded the asset to the destinationUrl file location. /// You must copy/move this file to a more persisten/appropriate location /// </summary> public override void FinishedDownloading (NSUrlConnection connection, NSUrl destinationUrl) { Console.WriteLine ("-- Downloaded file: " + destinationUrl.Path); Console.WriteLine ("---Target issue location: " + _issue.ContentUrl.Path); var saveToFilename = System.IO.Path.Combine(_issue.ContentUrl.Path, "default.html"); if (!System.IO.File.Exists (saveToFilename)) System.IO.File.Move (destinationUrl.Path, saveToFilename); Console.WriteLine ("---File moved for issue: " + _issue.Name); //TODO: If you download a ZIP or something, process it in the background //UIApplication.SharedApplication.BeginBackgroundTask (); }
/// <summary> /// Connection has successfully downloaded the asset to the destinationUrl file location. /// You must copy/move this file to a more persisten/appropriate location /// </summary> public override void FinishedDownloading (NSUrlConnection connection, NSUrl destinationUrl) { Console.WriteLine ($"Downloaded file: {destinationUrl.Path}"); Console.WriteLine ($"Target issue location: {Issue.ContentUrl.Path}"); var saveToFilename = Path.Combine (Issue.ContentUrl.Path, "default.html"); if (!File.Exists (saveToFilename)) File.Move (destinationUrl.Path, saveToFilename); Console.WriteLine ($"File moved for issue: {Issue.Name}"); if (OnDownloadingFinished != null) OnDownloadingFinished (); }
public override void FinishedLoading(NSUrlConnection connection) { var downloadedImage = UIImage.LoadFromData(this.tempData); this.tempData = null; this.InvokeOnMainThread(() => { var imageView = this.tableView.CellAt(this.index).ViewWithTag(IncidentImageTag) as UIImageView; // check if the row was deallocated when the user scrolled away. ignore. if (imageView != null) { imageView.Image = downloadedImage; } }); }
public override void ReceivedData(NSUrlConnection connection, NSData data) { byte [] nb = new byte [result.Length + data.Length]; result.CopyTo(nb, 0); Marshal.Copy(data.Bytes, nb, result.Length, (int) data.Length); result = nb; uint receivedLen = data.Length; bytesReceived = (bytesReceived + receivedLen); //if(expectedBytes != NSUrlResponse.) { progress = ((bytesReceived/(float)expectedBytes)*100)/100; percentComplete = progress*100; Console.WriteLine(progress + " - " + percentComplete); //} }
protected override void Dispose (bool disposing) { if (url_connection != null) { url_connection.Dispose (); url_connection = null; } if (request != null) { request.BodyStream = null; request.Dispose (); request = null; } if (random_input_stream != null) { random_input_stream.Dispose (); random_input_stream = null; } base.Dispose (disposing); }
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path) { tableView.DeselectRow(path, false); if (loading) return; var cell = GetActiveCell(); var spinner = StartSpinner(cell); loading = true; var request = new NSUrlRequest(new NSUrl(apiNode.ApiUrl), NSUrlRequestCachePolicy.UseProtocolCachePolicy, 60); var connection = new NSUrlConnection(request, new ConnectionDelegate((data, error) => { var apiNodes = DrupalApiParser.ParseJsonStream(data); loading = false; spinner.StopAnimating(); spinner.RemoveFromSuperview(); string childType = apiNode["childType"]; if (this.Count == 0) Add(new Section("")); else this[0].Clear(); foreach (var element in apiNodes) { this[0].Add(CreateElement(element, apiNode)); } var newDvc = new DialogViewController(this, true) { Autorotate = true }; PrepareDialogViewController(newDvc); dvc.ActivateController(newDvc); return; })); }
public override void ReceivedData(NSUrlConnection connection, NSData d) { data.AppendData (d); }
public override void ReceivedAuthenticationChallenge(NSUrlConnection connection, NSUrlAuthenticationChallenge challenge) { // if (challenge.PreviousFailureCount > 0) { // showError = false; // challenge.Sender.CancelAuthenticationChallenge (challenge); // Application.AuthenticationFailure (); // return; // } // // if (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodServerTrust") // challenge.Sender.UseCredentials (NSUrlCredential.FromTrust (challenge.ProtectionSpace.ServerTrust), challenge); // // if (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodDefault" && // Application.Account != null && Application.Account.Login != null && Application.Account.Password != null) { // challenge.Sender.UseCredentials (NSUrlCredential.FromUserPasswordPersistance ( // Application.Account.Login, Application.Account.Password, NSUrlCredentialPersistence.None), challenge); // } }
public override void FinishedLoading(NSUrlConnection connection) { Comms.ConnectionEnded (_name); callback (data.ToString ()); }
public override void FailedWithError(NSUrlConnection connection, NSError error) { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; if (showError) //Application.ShowNetworkError (error.LocalizedDescription); new UIAlertView("Network Error", "Communications problem", null, "Close").Show(); if (_failure != null) _failure (); }
public override bool CanAuthenticateAgainstProtectionSpace(NSUrlConnection connection, NSUrlProtectionSpace protectionSpace) { return true; }
public override void ReceivedData (NSUrlConnection connection, NSData data) { del.currentLength += data.Length; hud.Progress = (del.currentLength / (float) del.expectedLength); }
public override void FailedWithError (NSUrlConnection connection, NSError error) { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; if (showError) //Application.ShowNetworkError(error.LocalizedDescription); if (_failure!=null) _failure(error); }
public override void CanceledAuthenticationChallenge (NSUrlConnection connection, NSUrlAuthenticationChallenge challenge) { //Console.WriteLine("canceled"); }
public override void ReceivedAuthenticationChallenge (NSUrlConnection connection, NSUrlAuthenticationChallenge challenge) { if (challenge.PreviousFailureCount>0){ showError = false; challenge.Sender.CancelAuthenticationChallenge(challenge); return; } if (challenge.ProtectionSpace.AuthenticationMethod=="NSURLAuthenticationMethodServerTrust") challenge.Sender.UseCredentials(NSUrlCredential.FromTrust(challenge.ProtectionSpace.ServerTrust), challenge); if (challenge.ProtectionSpace.AuthenticationMethod=="NSURLAuthenticationMethodDefault" && _credential!=null) { challenge.Sender.UseCredentials(_credential, challenge); } }
void ShowUrl () { // Show the hud on top most view hud = MTMBProgressHUD.ShowHUD(this.navController.View, true); // Regiser for DidHide Event so we can remove it from the window at the right time hud.DidHide += HandleDidHide; NSUrl url = new NSUrl("https://github.com/matej/MBProgressHUD/zipball/master"); NSUrlRequest request = new NSUrlRequest(url); NSUrlConnection connection = new NSUrlConnection(request, new MyNSUrlConnectionDelegete(this, hud)); connection.Start(); }
public override void FailedWithError (NSUrlConnection connection, NSError error) { hud.Hide(true); }
public override void FinishedLoading (NSUrlConnection connection) { UrlConnection.ConnectionEnded(_name); if (strCallback!=null) strCallback(data.ToString()); if (imgCallback!=null) imgCallback(UIImage.LoadFromData(data)); }
public override void ReceivedResponse (NSUrlConnection connection, NSUrlResponse response) { del.expectedLength = response.ExpectedContentLength; del.currentLength = 0; hud.Mode = MBProgressHUDMode.Determinate; }