-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Description
Chromium is moving from an in-process network stack implementation to a separate NetworkService process.
Due to Chromium
changes CEF
will be implementing some dramatic API
changes. Relevant upstream
issue is https://bitbucket.org/chromiumembedded/cef/issues/2622/implement-support-for-networkservice
Chromium
is moving to a Network Service
, this means that network requests will be handled using a separate process, just like rendering, gpu acceleration, etc.
Known behaviour changes:
- Modifying the
newUrl
parameter inOnResourceRedirect
will no longer result in the method being called an additional time (likely a bug in the old implementation). - Modifying the request URL in
OnResourceResponse
would previously cause a redirect. This behaviour is now deprecated because the NetworkService does not support this functionality when using default network loaders. Temporary support has been added in combination withIResourceHandler
usage only. - Other changes to the request object inOnResourceResponse
will now cause the request to be restarted. This means thatOnBeforeResourceLoad
, etc, will be called an additional time with the new request information. IResponse.MimeType
will now be empty for non-200 responses.- Requests using custom schemes can now be handled via
IResourceRequestHandler
with the same callback behaviour as builtin schemes. - Redirects of custom scheme requests will now be followed as expected.
- Default handling of builtin schemes can now be disabled by setting
disableDefaultHandling
to true inGetResourceRequestHandler
. - Unhandled requests (custom scheme or builtin scheme with default handling disabled) will fail with an
Response.Error
value of ERR_UNKNOWN_URL_SCHEME. - The
ISchemeHandlerFactory.Create
callback will now include cookie headers. - Unsupported chrome hosts no longer redirect to chrome://version.
- All
CachePath
values must be relative to a newCefSettings.RootCachePath
value. ICookieManager
callbacks are now executed on theCEF UI
thread (previously theCEF IO
thread).- Resource-related callbacks have been moved from
IRequestHandler
to a newIResourceRequestHandler
interface which is returned via theIRequestHandler.GetResourceRequestHandler
method. If theIRequestHandler
declines to handle a resource it can optionally be handled by theIRequestContextHandler
, if any, associated with the loading context. - The
OnProtocolExecution
callback has been moved fromIRequestHandler
toIResourceRequestHandler
and will be called if a custom scheme request is unhandled. - Cookie send/save permission callbacks have been moved from
IRequestHandler
andIResourceHandler
toIResourceRequestHandler
. - New methods added to
IResourceHandler
that better match NetworkService execution sequence expectations. The old methods are now deprecated. - New methods added to
IRequest
andIResponse
. - All pending and in-progress requests will now be aborted when the CEF context
or associated browser is destroyed. The OnResourceLoadComplete callback will
now also be called in this case for in-progress requests that have a handler. - The
IResourceHandler.Cancel
method will now always be called when resource
handling is complete, irrespective of whether handling completed successfully. - Request callbacks that arrive after the
OnBeforeClose
callback for the
associated browser (which may happen for in-progress requests that are aborted
on browser destruction) will now always have a non-nullptrIBrowser
parameter. - Allow empty parameters to
IRequest
andIResponse
methods where it makes
sense (e.g. resetting default response state, or clearing a referrer value). - Modifying the URL in OnBeforeResourceLoad causes an internal redirect response.
- In cases where the request is cross-origin (containing a non-null "Origin"
header) the redirect response must include the "Access-Control-Allow-Origin"
header, otherwise the request will be blocked. - For 303 redirects all request methods except HEAD are converted to GET as per
the latest http draft. For historical reasons the draft also allows POST
requests to be converted to GETs when following 301/302 redirects. Most major
browsers do this and so shall we. When a request is converted to GET any POST
data should also be removed. - Use 307 redirects instead if you want the request to be repeated using the same
method and POST data.
API changes:
- Add
IResourceRequestHandler
- Add
ICookieAccessFilter
IRequestHandler.OnBeforeResourceLoad
moved toIResourceRequestHandler.OnBeforeResourceLoad
IRequestHandler.OnResourceRedirect
moved toIResourceRequestHandler.OnResourceRedirect
IRequestHandler.OnResourceResponse
moved toIResourceRequestHandler.OnResourceResponse
IRequestHandler.GetResourceResponseFilter
moved toIResourceRequestHandler.GetResourceResponseFilter
IRequestHandler.OnResourceLoadComplete
moved toIResourceRequestHandler.OnResourceLoadComplete
IRequestHandler.OnProtocolExecution
moved toIResourceRequestHandler.OnProtocolExecution
IRequestHandler.GetAuthCredentials
signature change,IFrame frame
replaced withstring originUrl
IDragHandler.OnDraggableRegionsChanged
now includes theIFrame
param
Cookie Handling
- Cookies are access is now handled using
ICookieAccessFilter
which is returned usingIResourceRequestHandler.GetCookieAccessFilter
- Removed
IRequestHandler.CanGetCookie
- Removed
IRequestHandler.CanSetCookie
- Removed
IResourceHandler.CanGetCookie
- Removed
IResourceHandler.CanSetCookie
- Removed
ICookieManager.CreateManager
- Removed
ICookieManager.GetBlockingManager
- Removed
ICookieManager.SetStoragePath
- Removed
IRequestContextHandler.GetCookieManager
IRequestContext.GetDefaultCookieManager
renamed toIRequestContext.GetCookieManager
ICookieManager.SetSupportedSchemes
has additionalbool includeDefaults
param.
Request/Scheme Handling
The IRequestHandler
interface has been rewritten as the CEF API
changed
- Ability to
Seek
within a stream has been added - Instead of implementing
IRequestHandler
directly it's reccomended for most cases to inherit fromRequestHandler
and overrideProcessRequestAsync
. See https://github.com/cefsharp/CefSharp/blob/cefsharp/75/CefSharp.Example/CefSharpSchemeHandler.cs for an example.
ResourceHandler Headers
IRequest
now has SetHeaderByName and GetHeaderByName which greatly simplifies header get/set.
CefSharp Specific API Changes
IResourceHandler.ProcessRequestAsync
now returnsCefReturnValue
instead ofbool
.IResourceHandler.ProcessRequestAsync
is now called inIResourceHandler.Open
which is a new method, as the structure has changed.IResourceHandler.GetResponse
has been removed- 'DefaultRequestHandler' renamed to
RequestHandler
(DefaultRequestHandler
exists as a class for now that's marked asObsolete
) RequestHandler
now implementsIRequestHandler
explicitly an exposesprotected virtual
methods to override, previously they were public.ISchemeRegistrar.AddCustomScheme
now takes a set ofSchemeOptions
flags to represent the different options instead of a bool for each param type. Brings the interface in line with theCEF API
.CefSharp.Legacy.LegacyResourceHandlerFactory
has been removed.
UweKeim, kiewic, GieltjE, MarcosMeli, shkdee and 3 more