Commit Graph

67 Commits

Author SHA1 Message Date
Alex Maitland 840790b479 Core - ResourceHandler.ForErrorMessage auto dispose of Stream
Dispose of stream when done, cannot reuse ResourceHandler.

Follow up to https://github.com/cefsharp/CefSharp/pull/4119
2022-08-09 11:23:59 +10:00
chylex 48280b7d32 Fix not disposing callback in ResourceHandler.Skip (#3978) 2022-01-21 15:09:35 +10:00
Alex Maitland edd764de5b Core - ResourceHandler.GetMimeType remove Obsolete
There are cases where it's preferable to use the CefSharp specific version as
the Chromium implementation queries the registry. There are cases where
the CefSharp implementation differs from the Chromium implementation.

Remove Obsolete attribute, no current plans to remove the method.
2021-04-30 13:20:29 +10:00
GitHubPang 8afe0dfca6 Fix typos (#3329) 2020-12-31 14:47:11 +10:00
amaitland 213a6e326d Core - ResourceHandler default Access-Control-Allow-Origin to * 2020-06-09 14:14:12 +10:00
amaitland b888c41fb7 Revert "Core - Remove ResourceHandler.GetMimeType"
This reverts commit 1b5e82814d4e49ab3b0ab249ad85c6254515a459.
2020-05-15 20:26:43 +10:00
amaitland 5cdc1f747e Core - Remove ResourceHandler.GetMimeType
It's actually made private for now as it's used in one place and
will be removed when that obsolete method is removed.

Resolves #3105
2020-05-15 20:26:42 +10:00
amaitland 14072b48e3 Core - ResourceHandler.Skip return true on successful seek 2020-04-23 17:07:06 +10:00
amaitland 2b47cf56ce Core - Make ResourceHandler.GetMimeType obsolete
Instead use Cef.GetMimeType to use the Chromium MimeType Mappings

Rather than maintain our own mapping (which is out of date) we'll defer to Chromium.

Make ResourceHandler.FromString(string, string) and ResourceHandler.GetMimeType obsolete, they will be removed at some point
ResourceHandler.FromString uses ResourceHandler.GetMimeType internally, Replacing with ResourceHandler.FromString(resource, mimeType: Cef.GetMimeType(extension));
uses a different overload.

Issue #3041
2020-03-26 08:50:08 +10:00
amaitland 006445df03 MimeType - Add extra checking to Cef.GetMimeType
Also update the ResourceHandler.FromFilePath xml doc to reference Cef.GetMimeType

Issue #3041
2020-03-26 08:50:07 +10:00
amaitland 0772121f5f Core - ResourceHandler Add MimeType Mappings
Adding some newer video/audio/font mappings

#3041
2020-02-05 11:41:02 +10:00
amaitland 5780fb1f58 Core - ResourceHandler free resources in Dispose instead of Cancel
There is no example of Cancel in the source code and the description in the doc doesn't
really provide a clear explanation of it's intended use case.

See code comment for further details
2020-02-05 10:06:48 +10:00
amaitland bf41aa2d75 Core - ResourceHandler.Read only read as many bytes as can be written to DataOut
Previously we'd read too many bytes and attempting to write them to dataOUt would cause a see System.NotSupportedException

Resolves #3038
2020-02-05 07:12:08 +10:00
amaitland 1155ef107c Core - ResourceHandler set Stream.Position = 0 and if CanSeek
- Prior to version 75 the Stream.Position was set to 0 before the ResourceHandler would read the Stream.
This restores that behaviour.
- Minor refactor of if statement for Stream.Can seek, only override ResponseLength with Stream.Length of not already set

Resolves #2903
2020-01-23 07:56:13 +10:00
amaitland 00f8cdf59b Core - ResourceHandler add Charset optional param to constructor or FromStream 2019-12-13 18:59:20 +10:00
amaitland 453f8d2077 Core - ResourceHandler now reuses it's temp byte[] buffer 2019-12-11 18:21:19 +10:00
amaitland 5ec1dbfe78 ResourceHandler - Rename CharSet to CharSet 2019-06-25 19:24:57 +10:00
amaitland 7eff7d17c0 ResourceHandler - Add new methods and callbacks
Now uses IResourceHandler.Open to call IResourceHandler.ProcessRequestAsync
IResourceHandler.ProcessRequestAsync now returns CefReturnValue instead of bool as there are three states
2019-06-25 19:24:57 +10:00
amaitland 73a156fdc5 Initial version 75 upgrade and NetworkService changes
Compiles, that's about it at this point, there are major CEF breaking changes, and lots to be addressed.

Browser Process (main process)
- Removed IResourceHandlerFactory as it no longer fits with the structure that CEF provides
- New IResourceRequestHandler interface added, not plumbed in yet
- CefSettings - Add RootCachePath and ApplicationClientIdForFileScanning

BrowserSubprocess (render process)
- SendProcessMessage was moved from CefBrowser to CefFrame
- OnBrowserCreated added extraInfo param

The BrowserSubprocess changes for this upgrade should be complete
2019-06-25 19:24:57 +10:00
Chris bef5dd37c4 Maintenance - Fixed formatting, file encoding, and copyright year (#2504)
* Applied formatting

* Fixed file encoding + Updated copyright year

* Updated License

* Fixed more file encoding

* Copyright notice now shows the year the file was created
2018-09-10 10:41:13 +10:00
amaitland d14c26a892 IResponse.ResponseHeaders - Make obsolete
Use IResponse.Headers instead
2018-08-07 19:33:51 +10:00
amaitland 5adff7014b ResourceHandler - Expose AutoDisposeStream for ResourceHandler.FromStream and ResourceHandler.FromFilePath
Also add OneTime param to WebBrowserExtensions.RegisterResourceHandler which translates to AutoDisposeStream
2018-05-17 16:43:14 +10:00
amaitland 7d720c6f80 ResourceHandler.FromFilePath - Remove Obsolete attribute
Update to use File.OpenRead and FromStream method instead
2018-03-05 16:36:22 +10:00
amaitland 5a5ba89ebf ResourceHandler.FromFilePath - Mark as Obsolete
There are problems with multiple concurrent calls to the underlying CefResourceHandler

See #2041 for background
2018-03-05 16:14:19 +10:00
amaitland 6691d0080a Refactor ResourceHandler, split FileResourceHandler out into it's own class, rather than relaying on ResourceHandlerType - this allows us to add more underlying CEF type wrappers without a huge amount of effort now.
Add new ByteArrayResourceHandler - uses CefStreamReader::CreateForData to load the byte array, for use with CefStreamResourceHandler
Add ResourceHandler.FromByteArray method for ease of use
Change ResourceHandler.FromString to use the new ByteArrayResourceHandler class
2017-05-05 12:55:44 +10:00
amaitland b357b736bb Set ResponseLength when Stream.CanSeek
Don't attempt to write bytes when the bytesRead count is 0
2017-04-06 17:25:34 +10:00
amaitland 440cc7a67c Remove ResourceHandler.FromFileName - was marked as Obsolete a while back 2017-04-06 16:05:18 +10:00
amaitland 7bf33f4a36 Expose ResourceH.GetMemoryStream - turns a string into a memory stream and optionally appends a BOM to the beginning 2017-03-06 08:55:07 +10:00
Chris cd934267c6 Updated copyright year and made sure it used same format everywhere (#1966) 2017-03-06 08:44:37 +10:00
amaitland 9df1bc132c Add RegisterResourceHandler and UnRegisterResourceHandler to simplify using the DefaultResourceHandlerFactory 2016-12-08 22:14:09 +10:00
amaitland 153296df63 Add ErrorCode to ResourceHandler - can now set the IResponse.ErrorCode without having to manually implement IResourceHandler 2016-06-22 11:52:15 +10:00
amaitland 04d2a8ede8 Add ResourceHandler.FromFilePath method that takes in a MimeType
Make ResourceHandler.FromFileName obsolete
2016-06-16 15:16:30 +10:00
amaitland 9d5abddc9a Fix typos 2016-06-01 16:30:34 +10:00
amaitland e97fe18165 ResourceHandler - Add AutoDisposeStream (Stream will be disposed when the ResourceHandler is Disposed) 2016-06-01 15:09:58 +10:00
amaitland 3061becb3f IResourceHandler now implements IDisposable - you can cleanup and resources when the handler is disposed 2016-05-26 07:28:19 +10:00
amaitland 560fa2b867 Improve ResourceHandler documentation, add a minor simplification and update the FlashResourceHandler example to demo how simple it is to use a ResourceHandler when extending FlashResourceHandler 2016-04-15 16:25:06 +10:00
amaitland 12f42331dc Resolves #1592 - Expose all methods of CefResourceHandler
Previously we were passing in the frame, request wrappers which hadn't been used, so just keep things simple and remove the code.
Current users should extend ResourceHandler instead of IResourceHandler and add the override keyword
TODO: Deal with setting bytesRead property - currently using Stream.Length which won't work for every stream type
2016-02-18 16:44:51 +10:00
amaitland bae3c28e92 Update copyright to 2016 2016-01-11 14:11:30 +10:00
Atvaark b04ccbb269 Add missing comments 2015-11-04 13:10:00 +10:00
Alex Maitland 042f873975 Resolve issue with loging plugin diagnostic page - MimeType was null which crashed unexpectedly
Added validation so that MimeType is required or exception throw
Remove some of the method overloads and replace with default params on the main methods
2015-08-09 12:26:00 +10:00
amaitland 2f863b5c9b Make MimeType directly settable - think that's the last change required to make it flexible 2015-07-29 21:14:15 +10:00
amaitland 9225da0a26 Make constructor public again, guess it's possible that you would need an empty ResourceHandler with a different StatusCode for example 2015-07-29 21:12:29 +10:00
amaitland 88b02ba904 Add ResourceHandlerType to deal with Files differently, use the underlying CefStreamReader::CreateForFile implementation 2015-07-29 20:49:29 +10:00
amaitland 864f9ea7a2 Rename GetResponseHeaders to GetResponse 2015-06-15 23:07:02 +10:00
amaitland afbed86524 First draft of what is hopefully the final rewrite of ResourceHandler/SchemeHandler
This will built but won't run as CefResponseWrapper has not yet been implemented.
2015-06-15 21:03:25 +10:00
amaitland c193020c72 Change public API to use Continue and Cancel methods - callback is then somewhat more consistent with other callback wrappers 2015-06-05 12:17:12 +10:00
amaitland c8d73574da Add cancel param to ProcessRequestCallback - previously only able to call the Continue() method on the callback 2015-06-05 12:12:33 +10:00
Bill Tutt 1df0d648a8 Don't create a task for MemoryStreams, and some more Resharper Cleanups. 2015-05-28 22:14:34 -04:00
amaitland 2983bf7383 Change ContentLength to be a long (int64)
Set ContentLength in ResourceHandler when using a MemoryStream
2015-05-27 18:01:17 +10:00
amaitland 187b255730 Change ResourceHandler to use explicit IResourceHandler interface implementation
Add some extra spacing and fix up a comment
2015-05-27 17:17:29 +10:00