当前位置: 首页>>代码示例>>C#>>正文


C# IRequest.GetCharSet方法代码示例

本文整理汇总了C#中IRequest.GetCharSet方法的典型用法代码示例。如果您正苦于以下问题:C# IRequest.GetCharSet方法的具体用法?C# IRequest.GetCharSet怎么用?C# IRequest.GetCharSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRequest的用法示例。


在下文中一共展示了IRequest.GetCharSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: using

        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;
        }
开发者ID:bjarteskogoy,项目名称:CefSharp,代码行数:35,代码来源:RequestHandler.cs

示例2: using

        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;
        }
开发者ID:haozhouxu,项目名称:CefSharp,代码行数:47,代码来源:RequestHandler.cs

示例3: Uri

        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;
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:60,代码来源:SixWebControlBehavior.cs

示例4: Uri

        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;
        }
开发者ID:Antonyo,项目名称:CefSharp,代码行数:66,代码来源:RequestHandler.cs


注:本文中的IRequest.GetCharSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。