CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } return CefReturnValue.Continue; }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { if (CommonUrls.IsWithSixUrl(request.Url)) { var headers = request.Headers; headers[Common.ClientHeader] = DomainEvilGlobal.SecretData.UserInfo.ClientId.ToString(); headers[Common.ClientHeaderV] = Common.App.ProductVersion; request.Headers = headers; } return CefReturnValue.Continue; //Example of how to set Referer // Same should work when setting any header // For this example only set Referer when using our custom scheme var url = new Uri(request.Url); if (url.Scheme == "customscheme") // CefSharpSchemeHandlerFactory.SchemeName { var headers = request.Headers; headers["Referer"] = "http://google.com"; request.Headers = headers; } //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { if (postData != null) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } } return CefReturnValue.Continue; }
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { try { //To allow certificate //callback.Continue(true); //return true; return false; } finally { callback.Dispose(); } }
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { //To allow certificate //callback.Continue(true); //return true; } } return false; }
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { //To allow certificate //callback.Continue(true); //return true; } } return false; }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { if(postData != null) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } } return CefReturnValue.Continue; }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { // For some reason, in order to set cookies manually using a hdeader you need to clear the real cookies every time :/ Cef.GetGlobalCookieManager().VisitAllCookies(new DeleteAllCookiesVisitor()); if (request.Url.StartsWith("steammobile://")) { // Cancel all steammobile:// requests (for the app) return CefReturnValue.Cancel; } else { var headers = request.Headers; headers.Add("Cookie", Cookies); headers.Add("X-Requested-With", "com.valvesoftware.android.steam.community"); request.Headers = headers; return CefReturnValue.Continue; } }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { try { //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } finally { callback.Dispose(); } return CefReturnValue.Continue; }
public void MakeCall( string apicall, Hashtable args, IRequestCallback cb, bool requires_auth_token ) { unityObject.DoCoroutine( SendCore( apicall, args, cb, requires_auth_token ) ); }
protected IEnumerator SendCore( string apicall, Hashtable args, IRequestCallback<IXMLNode> cb ) { if ( GameKey == "") { logger.DebugLog("[roar] -- No game key set!--"); yield break; } logger.DebugLog("[roar] -- Calling: "+apicall); // Encode POST parameters WWWForm post = new WWWForm(); if(args!=null) { foreach (DictionaryEntry param in args) { //Debug.Log(string.Format("{0} => {1}", param.Key, param.Value)); post.AddField( param.Key as string, param.Value as string ); } } // Add the auth_token to the POST post.AddField( "auth_token", RoarAuthToken ); // Fire call sending event RoarManager.OnRoarNetworkStart(); //Debug.Log ( "roar_api_url = " + RoarAPIUrl ); if (Debug.isDebugBuild) Debug.Log ( "Requesting : " + RoarAPIUrl+GameKey+"/"+apicall+"/" ); var xhr = new WWW( RoarAPIUrl+GameKey+"/"+apicall+"/", post); yield return xhr; OnServerResponse( xhr.text, apicall, cb ); }
protected void OnServerResponse( string raw, string apicall, IRequestCallback<IXMLNode> cb ) { var uc = apicall.Split("/"[0]); var controller = uc[0]; var action = uc[1]; Debug.Log(raw); // TEMP /* if (apicall == "shop/list") { raw = "<roar tick=\"135170282509\"><shop><list status=\"ok\"><shopitem ikey=\"rocket_fuel\" label=\"Rocket Fuel\" description=\"\"><costs><stat_cost type=\"currency\" ikey=\"gamecoins\" value=\"10\" ok=\"true\"/></costs><modifiers><grant_stat type=\"currency\" ikey=\"rocket_fuel\" value=\"100\"/></modifiers><tags/></shopitem><shopitem ikey=\"neil_armstrong\" label=\"Neil Armstrong\" description=\"Best copilot in the world\"><costs><stat_cost type=\"currency\" ikey=\"premium_currency\" value=\"15\" ok=\"false\" reason=\"Insufficient Premium Currency\"/></costs><modifiers><grant_item ikey=\"npc_armstrong\"/></modifiers><tags><tag value=\"copilot\"/></tags></shopitem><shopitem ikey=\"starter_space_pack\" label=\"Starter Space Pack\" description=\"Get going!\"><costs><stat_cost type=\"currency\" ikey=\"gamecoins\" value=\"20\" ok=\"true\"/></costs><modifiers><grant_stat type=\"currency\" ikey=\"rocket_fuel\" value=\"30\"/><grant_item ikey=\"regular_space_helmet\"/><grant_item ikey=\"rocket_ship\"/></modifiers><tags><tag value=\"pack\"/></tags></shopitem></list></shop></roar>"; } */ // Fire call complete event RoarManager.OnRoarNetworkEnd("no id"); // -- Parse the Roar response // Unexpected server response if (raw[0] != '<') { // Error: fire the error callback IXMLNode errorXml = IXMLNodeFactory.instance.Create("error", raw); if (cb!=null) cb.OnRequest( new Roar.CallbackInfo<IXMLNode>(errorXml, IWebAPI.FATAL_ERROR, "Invalid server response" ) ); return; } IXMLNode rootNode = IXMLNodeFactory.instance.Create( raw ); int callback_code; string callback_msg=""; IXMLNode actionNode = rootNode.GetNode( "roar>0>"+controller+">0>"+action+">0" ); // Hash XML keeping _name and _text values by default // Pre-process <server> block if any and attach any processed data IXMLNode serverNode = rootNode.GetNode( "roar>0>server>0" ); RoarManager.NotifyOfServerChanges( serverNode ); // Status on Server returned an error. Action did not succeed. string status = actionNode.GetAttribute( "status" ); if (status == "error") { callback_code = IWebAPI.UNKNOWN_ERR; callback_msg = actionNode.GetFirstChild("error").Text; string server_error = actionNode.GetFirstChild("error").GetAttribute("type"); if ( server_error == "0" ) { if (callback_msg=="Must be logged in") { callback_code = IWebAPI.UNAUTHORIZED; } if (callback_msg=="Invalid auth_token") { callback_code = IWebAPI.UNAUTHORIZED; } if (callback_msg=="Must specify auth_token") { callback_code = IWebAPI.BAD_INPUTS; } if (callback_msg=="Must specify name and hash") { callback_code = IWebAPI.BAD_INPUTS; } if (callback_msg=="Invalid name or password") { callback_code = IWebAPI.DISALLOWED; } if (callback_msg=="Player already exists") { callback_code = IWebAPI.DISALLOWED; } logger.DebugLog(string.Format("[roar] -- response error: {0} (api call = {1})", callback_msg, apicall)); } // Error: fire the callback // NOTE: The Unity version ASSUMES callback = errorCallback if (cb!=null) cb.OnRequest( new Roar.CallbackInfo<IXMLNode>(rootNode, callback_code, callback_msg) ); } // No error - pre-process the result else { IXMLNode auth_token = actionNode.GetFirstChild("auth_token"); if (auth_token!=null) RoarAuthToken = auth_token.Text; callback_code = IWebAPI.OK; if (cb!=null) cb.OnRequest( new Roar.CallbackInfo<IXMLNode>( rootNode, callback_code, callback_msg) ); } RoarManager.OnCallComplete( new RoarManager.CallInfo( rootNode, callback_code, callback_msg, "no id" ) ); }
protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser webBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { if (IsMailtoUrl(request.Url)) { return(CefReturnValue.Cancel); } AppendCustomHeaders(webBrowser, request); ReplaceSebScheme(request); return(base.OnBeforeResourceLoad(webBrowser, browser, frame, request, callback)); }
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { callback.Dispose(); return false; }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { //Example of how to set Referer // Same should work when setting any header // For this example only set Referer when using our custom scheme var url = new Uri(request.Url); if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) { //Referrer is now set using it's own method (was previously set in headers before) request.SetReferrer("http://google.com", ReferrerPolicy.Default); } //Example of setting User-Agent in every request. //var headers = request.Headers; //var userAgent = headers["User-Agent"]; //headers["User-Agent"] = userAgent + " CefSharp"; //request.Headers = headers; //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { if(postData != null) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } } return CefReturnValue.Continue; }
public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { return false; }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { var args = new OnBeforeResourceLoadEventArgs(browserControl, browser, frame, request, callback); OnBeforeResourceLoadEvent?.Invoke(this, args); EnsureCallbackDisposal(callback); return(args.ContinuationHandling); }
CefReturnValue IResourceRequestHandler.OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { return(OnBeforeResourceLoad(chromiumWebBrowser, browser, frame, request, callback)); }
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { var args = new OnQuotaRequestEventArgs(browserControl, browser, originUrl, newSize, callback); OnQuotaRequestEvent?.Invoke(this, args); EnsureCallbackDisposal(callback); return(args.ContinueAsync); }
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { var args = new OnCertificateErrorEventArgs(browserControl, browser, errorCode, requestUrl, sslInfo, callback); OnCertificateErrorEvent?.Invoke(this, args); EnsureCallbackDisposal(callback); return(args.ContinueAsync); }
public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { if (_notValid.Any(x => request.Url.Contains(x))) { return(CefReturnValue.Cancel); } return(CefReturnValue.Continue); }
protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { callback.Continue(true); return(true); }
protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser webBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { // TODO: CEF does not yet support intercepting requests from service workers, thus the user agent must be statically set at browser // startup for now. Once CEF has full support of service workers, the static user agent should be removed and the method below // reactivated. See https://bitbucket.org/chromiumembedded/cef/issues/2622 for the current status of development. // AppendCustomUserAgent(request); if (IsMailtoUrl(request.Url)) { return(CefReturnValue.Cancel); } ReplaceSebScheme(request); return(base.OnBeforeResourceLoad(webBrowser, browser, frame, request, callback)); }
public void TestOnServerResponse(string raw, string apicall, IRequestCallback cb) { OnServerResponse(raw, apicall, cb); }
protected virtual CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { return(CefReturnValue.Continue); }
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { // We shouldn't hit this, since IgnoreCertificateErrors is true return true; }
/// <summary> /// Called when JavaScript requests a specific storage quota size via the webkitStorageInfo.requestQuota function. /// For async processing return true and execute <see cref="IRequestCallback.Continue"/> at a later time to /// grant or deny the request or <see cref="IRequestCallback.Cancel"/> to cancel. /// </summary> /// <param name="browserControl">The ChromiumWebBrowser control</param> /// <param name="browser">the browser object</param> /// <param name="originUrl">the origin of the page making the request</param> /// <param name="newSize">is the requested quota size in bytes</param> /// <param name="callback">Callback interface used for asynchronous continuation of url requests.</param> /// <returns>Return false to cancel the request immediately. Return true to continue the request /// and call <see cref="IRequestCallback.Continue"/> either in this method or at a later time to /// grant or deny the request.</returns> public virtual bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { callback.Dispose(); return(false); }
public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { return CefReturnValue.Continue; }
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { //Accept Request to raise Quota //callback.Continue(true); //return true; } } return false; }
public OnQuotaRequestEventArgs(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) : base(browserControl, browser) { OriginUrl = originUrl; NewSize = newSize; Callback = callback; ContinueAsync = false; // default }
protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { if (IsTextResourceType(request)) { var url = request.Url; var requestStr = TryGetPostDataString(request); if (_requestsReplacer.IsRequestMustBeReplaced(url, requestStr, out var requestReplacedStr)) { TrySetPostDataString(request, requestReplacedStr); } } return(base.OnBeforeResourceLoad(chromiumWebBrowser, browser, frame, request, callback)); }
public void _set(Hashtable obj, IRequestCallback<IXMLNode> cb) { api.MakeCall ("user/set", obj, cb); }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { Uri url; if (Uri.TryCreate(request.Url, UriKind.Absolute, out url) == false) { throw new Exception("Request to \"" + request.Url + "\" can't continue, not a valid URI"); } //Example of how to set Referer // Same should work when setting any header // For this example only set Referer when using our custom scheme //if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) //{ // //Referrer is now set using it's own method (was previously set in headers before) // request.SetReferrer("http://google.com", ReferrerPolicy.Default); //} //Example of setting User-Agent in every request. //var headers = request.Headers; //var userAgent = headers["User-Agent"]; //headers["User-Agent"] = userAgent + " CefSharp"; //request.Headers = headers; //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { if (postData != null) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } } return(CefReturnValue.Continue); }
protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { //NOTE: We also suggest you wrap callback in a using statement or explicitly execute callback.Dispose as callback wraps an unmanaged resource. //Example #1 //Return true and call IRequestCallback.Continue() at a later time to continue or cancel the request. //In this instance we'll use a Task, typically you'd invoke a call to the UI Thread and display a Dialog to the user //You can cast the IWebBrowser param to ChromiumWebBrowser to easily access //control, from there you can invoke onto the UI thread, should be in an async fashion Task.Run(() => { //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { //We'll allow the expired certificate from badssl.com if (requestUrl.ToLower().Contains("https://expired.badssl.com/")) { callback.Continue(true); } else { callback.Continue(false); } } } }); return(true); //Example #2 //Execute the callback and return true to immediately allow the invalid certificate //callback.Continue(true); //Callback will Dispose it's self once exeucted //return true; //Example #3 //Return false for the default behaviour (cancel request immediately) //callback.Dispose(); //Dispose of callback //return false; }
// // Summary: // Called when JavaScript requests a specific storage quota size via the webkitStorageInfo.requestQuota // function. For async processing return true and execute CefSharp.IRequestCallback.Continue(System.Boolean) // at a later time to grant or deny the request or CefSharp.IRequestCallback.Cancel() // to cancel. // // Parameters: // originUrl: // the origin of the page making the request // // newSize: // is the requested quota size in bytes // // callback: // Callback interface used for asynchronous continuation of url requests. // // Returns: // Return false to cancel the request immediately. Return true to continue the // request and call CefSharp.IRequestCallback.Continue(System.Boolean) either // in this method or at a later time to grant or deny the request. public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { callback.Continue(true); return(true); }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { //Example of how to set Referer // Same should work when setting any header // For this example only set Referer when using our custom scheme var url = new Uri(request.Url); if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName) { var headers = request.Headers; headers["Referer"] = "http://google.com"; request.Headers = headers; } //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { if (postData != null) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } } return(CefReturnValue.Continue); }
public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { if (!parent.AllowInsecureCerts) { return(false); } callback.Continue(true); return(true); }
public void MakeCall( string apicall, Hashtable args, IRequestCallback<IXMLNode> cb ) { unityObject.DoCoroutine( SendCore( apicall, args, cb ) ); }
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { if (!callback.IsDisposed) { callback.Dispose(); } return(true); }
protected IEnumerator SendCore( string apicall, Hashtable args, IRequestCallback cb, bool requires_auth_token ) { if ( GameKey == "") { logger.DebugLog("[roar] -- No game key set!--"); yield break; } logger.DebugLog("[roar] -- Calling: "+apicall); // Encode POST parameters WWWForm post = new WWWForm(); if(args!=null) { foreach (DictionaryEntry param in args) { //Debug.Log(string.Format("{0} => {1}", param.Key, param.Value)); post.AddField( param.Key as string, param.Value as string ); } } if( requires_auth_token ) { AddAuthToken(args,post); } // Fire call sending event RoarManager.OnRoarNetworkStart(); //Debug.Log ( "roar_api_url = " + RoarAPIUrl ); if (Debug.isDebugBuild) Debug.Log ( "Requesting : " + RoarAPIUrl+GameKey+"/"+apicall+"/" ); //NOTE: This is a work-around for unity not supporting zero length body for POST requests if ( post.data.Length == 0 ) { post.AddField("dummy","x"); } var xhr = new WWW( RoarAPIUrl+GameKey+"/"+apicall+"/", post); yield return xhr; OnServerResponse( xhr.text, apicall, cb ); }
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { //To allow certificate //callback.Continue(true); //return true; } } return(false); }
protected void OnServerResponse( string raw, string apicall, IRequestCallback cb ) { var uc = apicall.Split("/"[0]); var controller = uc[0]; var action = uc[1]; if (Debug.isDebugBuild) Debug.Log(raw); // Fire call complete event RoarManager.OnRoarNetworkEnd("no id"); // -- Parse the Roar response // Unexpected server response if ( raw==null || raw.Length==0 || raw[0] != '<') { // Error: fire the error callback System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement error = doc.CreateElement("error"); doc.AppendChild(error); error.AppendChild(doc.CreateTextNode(raw)); if (cb!=null) { cb.OnRequest( new Roar.RequestResult( RoarExtensions.CreateXmlElement("error",raw), IWebAPI.FATAL_ERROR, "Invalid server response" ) ); } return; } System.Xml.XmlElement root = RoarExtensions.CreateXmlElement(raw); int callback_code; string callback_msg=""; System.Xml.XmlElement actionElement = root.SelectSingleNode( "/roar/"+controller+"/"+action ) as System.Xml.XmlElement; // Pre-process <server> block if any and attach any processed data System.Xml.XmlElement serverElement = root.SelectSingleNode( "/roar/server" ) as System.Xml.XmlElement; RoarManager.NotifyOfServerChanges( serverElement ); // Status on Server returned an error. Action did not succeed. string status = actionElement.GetAttribute( "status" ); if (status == "error") { callback_code = IWebAPI.UNKNOWN_ERR; callback_msg = actionElement.SelectSingleNode("error").InnerText; string server_error = (actionElement.SelectSingleNode("error") as System.Xml.XmlElement).GetAttribute("type"); if ( server_error == "0" ) { if (callback_msg=="Must be logged in") { callback_code = IWebAPI.UNAUTHORIZED; } if (callback_msg=="Invalid auth_token") { callback_code = IWebAPI.UNAUTHORIZED; } if (callback_msg=="Must specify auth_token") { callback_code = IWebAPI.BAD_INPUTS; } if (callback_msg=="Must specify name and hash") { callback_code = IWebAPI.BAD_INPUTS; } if (callback_msg=="Invalid name or password") { callback_code = IWebAPI.DISALLOWED; } if (callback_msg=="Player already exists") { callback_code = IWebAPI.DISALLOWED; } logger.DebugLog(string.Format("[roar] -- response error: {0} (api call = {1})", callback_msg, apicall)); } // Error: fire the callback // NOTE: The Unity version ASSUMES callback = errorCallback if (cb!=null) cb.OnRequest( new Roar.RequestResult(root, callback_code, callback_msg) ); } // No error - pre-process the result else { System.Xml.XmlElement auth_token = actionElement.SelectSingleNode(".//auth_token") as System.Xml.XmlElement; if (auth_token!=null && !string.IsNullOrEmpty(auth_token.InnerText)) RoarAuthToken = auth_token.InnerText; callback_code = IWebAPI.OK; if (cb!=null) cb.OnRequest( new Roar.RequestResult( root, callback_code, callback_msg) ); } RoarManager.OnCallComplete( new RoarManager.CallInfo( root, callback_code, callback_msg, "no id" ) ); }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { if (request.Method == "POST") { using (var postData = request.PostData) { var elements = postData.Elements; var charSet = request.GetCharSet(); foreach (var element in elements) { if (element.Type == PostDataElementType.Bytes) { var body = element.GetBody(charSet); } } } } //Note to Redirect simply set the request Url //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase)) //{ // request.Url = "https://github.com/"; //} //Callback in async fashion //callback.Continue(true); //return CefReturnValue.ContinueAsync; } } return(CefReturnValue.Continue); }
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { var uri = new Uri(request.Url); // We can get http requests just after changing Syncthing's address: after we've navigated to about:blank but before navigating to // the new address (Which we do when Syncthing hits the 'running' State). // Therefore only open external browsers if Syncthing is actually running if (this.syncthingManager.State == SyncthingState.Running && (uri.Scheme == "http" || uri.Scheme == "https") && uri.Host != this.syncthingManager.Address.NormalizeZeroHost().Host) { this.processStartProvider.StartDetached(request.Url); return CefReturnValue.Cancel; } // See https://github.com/canton7/SyncTrayzor/issues/13 // and https://github.com/cefsharp/CefSharp/issues/534#issuecomment-60694502 var headers = request.Headers; headers["X-API-Key"] = this.syncthingManager.ApiKey; lock (this.cultureLock) { if (this.culture != null) headers["Accept-Language"] = $"{this.culture.Name};q=0.8,en;q=0.6"; } request.Headers = headers; return CefReturnValue.Continue; }
public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { return(CefReturnValue.Continue); }
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { callback.Continue(true); return true; }
public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { return(false); }
public new void MakeCall( string apicall, Hashtable args, IRequestCallback cb, bool requires_auth_token ) { Assert.IsTrue(responses.ContainsKey(apicall), "no mock response setup for api path '" + apicall + "'"); OnServerResponse(responses[apicall] as String, apicall, cb); }
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { try { //Accept Request to raise Quota //callback.Continue(true); //return true; return false; } finally { callback.Dispose(); } }
public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { return false; }
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { if (BrowserUtils.HasDevTools) { NameValueCollection headers = request.Headers; headers.Remove("x-devtools-emulate-network-conditions-client-id"); request.Headers = headers; } return(base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback)); }
public new void make_call( string apicall, Hashtable args, IRequestCallback<IXMLNode> cb ) { Assert.IsTrue(responses.ContainsKey(apicall), "no mock response setup for api path '" + apicall + "'"); onServerResponse(responses[apicall] as String, apicall, cb); }
// // Summary: // Called before a resource request is loaded. For async processing return CefSharp.CefReturnValue.ContinueAsync // and execute CefSharp.IRequestCallback.Continue(System.Boolean) or CefSharp.IRequestCallback.Cancel() // // Parameters: // frame: // The frame object // // request: // the request object - can be modified in this callback. // // callback: // Callback interface used for asynchronous continuation of url requests. // // Returns: // To cancel loading of the resource return CefSharp.CefReturnValue.Cancel or // CefSharp.CefReturnValue.Continue to allow the resource to load normally. // For async return CefSharp.CefReturnValue.ContinueAsync public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { // if referer given var tab = myForm.GetTabByBrowser(browserControl); if (tab != null && tab.RefererURL != null) { // Set referer request.SetReferrer(tab.RefererURL, ReferrerPolicy.Always); } return(CefSharp.CefReturnValue.Continue); }
// // Summary: // Called on the CEF IO thread before a resource request is loaded. To redirect // or change the resource load optionally modify request. Modification of the request // URL will be treated as a redirect // // Parameters: // chromiumWebBrowser: // The ChromiumWebBrowser control // // browser: // the browser object - may be null if originating from ServiceWorker or CefURLRequest // // frame: // the frame object - may be null if originating from ServiceWorker or CefURLRequest // // request: // the request object - can be modified in this callback. // // callback: // Callback interface used for asynchronous continuation of url requests. // // Returns: // Return CefSharp.CefReturnValue.Continue to continue the request immediately. // Return CefSharp.CefReturnValue.ContinueAsync and call CefSharp.IRequestCallback.Continue(System.Boolean) // or CefSharp.IRequestCallback.Cancel at a later time to continue or the cancel // the request asynchronously. Return CefSharp.CefReturnValue.Cancel to cancel the // request immediately. public CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { // if referer given var tab = myForm.GetTabByBrowser(chromiumWebBrowser); if (tab != null && tab.RefererURL != null) { // Set referer request.SetReferrer(tab.RefererURL, ReferrerPolicy.ClearReferrerOnTransitionFromSecureToInsecure); } return(CefSharp.CefReturnValue.Continue); }
public new CefReturnValue OnBeforeResourceLoad(IWebBrowser webBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) { return(base.OnBeforeResourceLoad(webBrowser, browser, frame, request, callback)); }
public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) { return(false); }
public OnBeforeResourceLoadEventArgs(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) : base(browserControl, browser) { Frame = frame; Request = request; Callback = callback; ContinuationHandling = CefReturnValue.Continue; // default }
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { //Accept Request to raise Quota //callback.Continue(true); //return true; } } return false; }
bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) { //NOTE: If you do not wish to implement this method returning false is the default behaviour // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource. //callback.Dispose(); //return false; //NOTE: When executing the callback in an async fashion need to check to see if it's disposed if (!callback.IsDisposed) { using (callback) { //Accept Request to raise Quota //callback.Continue(true); //return true; } } return(false); }
public void view(Hashtable obj, IRequestCallback<IXMLNode> cb) { api.MakeCall ("user/view", null, cb); }
public OnCertificateErrorEventArgs(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) : base(browserControl, browser) { ErrorCode = errorCode; RequestUrl = requestUrl; SSLInfo = sslInfo; Callback = callback; ContinueAsync = false; // default }