Search code examples
awesomiumreferer

Awesomium, changing http referer in vb.net winforms


Well i couldn't find a answer for changing/setting custom http referer for awesomium in vb.net.

So can anyone help me out ?

Thank you very much.


Solution

  • Implement the Awesomium.Core.IResourceInterceptor interface and attach it to your webcore session with WebCore.ResourceInterceptor = new ResourceInterceptor();

    Here is a simple ResourceInterceptor in C#.

    using System;
    using System.IO;
    using System.Reflection;
    using Awesomium.Core;
    
    namespace MyApp
    {
        public class ResourceInterceptor : IResourceInterceptor
        {
            /// <summary>
            ///     Overwrites the HTTP_REFER request header
            /// </summary>
            public virtual ResourceResponse OnRequest(ResourceRequest request)
            {
              request.Referrer = "http://www.example.com;
            }
    
            /// <summary>
            ///     Optionally blocks any web browser requests by returning true
            /// </summary>
            public virtual bool OnFilterNavigation(NavigationRequest request)
            {
              return false;
            }
        }
    }