/// <summary> /// Send a GET request to the specified <see cref="Uri"/>. /// </summary> /// <param name="requestUri"> /// The <see cref="Uri"/> the request is sent to. /// </param> /// <param name="referrerUri"> /// The <see cref="Uri"/> of the referring site for a request. Can be null. /// </param> /// <param name="referrerPolicy"> /// The policy for how the Referrer HTTP header value will be sent during request. /// </param> /// <param name="headers"> /// A <see cref="NameValueCollection"/> containing header name/value pairs associated with a request. Can be null. /// </param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <exception cref="ArgumentNullException">The <see cref="requestUri"/> parameter is null.</exception> public async Task <CefNetWebRequest> GetAsync(Uri requestUri, Uri referrerUri, CefReferrerPolicy referrerPolicy, NameValueCollection headers, CancellationToken cancellationToken) { if (requestUri is null) { throw new ArgumentNullException(nameof(requestUri)); } var r = new CefRequest(); r.Flags = (int)this.RequestFlags; r.Url = requestUri.AbsoluteUri; if (referrerUri != null) { r.SetReferrer(referrerUri.AbsoluteUri, referrerPolicy); } if (headers != null && headers.Count > 0) { using (var map = new CefStringMultimap()) { map.Add(headers); r.SetHeaderMap(map); } } var request = new CefNetWebRequest(this); await request.SendAsync(r, _context, cancellationToken); return(request); }
private void HandleLoadFromString(object sender, EventArgs e) { if (!CefCommandLine.Global.HasSwitch("disable-site-isolation-trials")) { // info: // https://magpcss.org/ceforum/viewtopic.php?f=6&t=17176&p=43706 // https://bitbucket.org/chromiumembedded/cef/issues/2586 MessageBox.Show("This test only works with --disable-site-isolation-trials."); } var view = SelectedView as CustomWebView; if (view is null) { return; } Guid sourceKey = Guid.NewGuid(); view.AddSource(sourceKey, new StringSource("Hello, world!", "text/html")); var request = new CefRequest(); request.Url = "http://example.com"; request.SetReferrer("https://www.google.com/", CefReferrerPolicy.NeverClearReferrer); request.SetHeaderByName("CefNet-Source", sourceKey.ToString(), false); // see CustomWebViewGlue.GetResourceHandler() SelectedView?.GetMainFrame().LoadRequest(request); }
protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool userGesture, bool isRedirect) { base.OnBeforeBrowse(browser, frame, request, userGesture, isRedirect); if (request.ReferrerURL == null) { request.SetReferrer(_referer, CefReferrerPolicy.Default); } return(false); }
private void HandleLoadFromString(object sender, EventArgs e) { var view = SelectedView as CustomWebView; if (view is null) { return; } Guid sourceKey = Guid.NewGuid(); view.AddSource(sourceKey, new StringSource("Hello, world!", "text/html")); var request = new CefRequest(); request.Url = "http://example.com"; request.SetReferrer("https://www.google.com/", CefReferrerPolicy.NeverClearReferrer); request.SetHeaderByName("CefNet-Source", sourceKey.ToString(), false); // see CustomWebViewGlue.GetResourceHandler() SelectedView?.GetMainFrame().LoadRequest(request); }
protected override CefReturnValue OnBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request, CefRequestCallback callback) { request.SetReferrer(request.ReferrerURL, CefReferrerPolicy.Origin); return(CefReturnValue.Continue); }
protected override CefResourceHandler GetResourceHandler(CefBrowser browser, CefFrame frame, CefRequest request) { request.SetReferrer(request.ReferrerURL, CefReferrerPolicy.Origin); //return new CefWebResourceHandler(); return(null); }