cztomczak / cefpython

Python bindings for the Chromium Embedded Framework (CEF)
Other
3.08k stars 473 forks source link

Example of serving content using http://myapp/ url - allows to bypass file:// protocol restrictions #465

Open cztomczak opened 6 years ago

cztomczak commented 6 years ago

Loading content using file:// protocol has many restrictions. Does't integrate well with http content, cookies don't work, local storage is shared across all urls, Origin header (CRSF) doesn't work, CORS issues with files accessing each other (e.g. between directories), etc. Serving content using http://myapp/ url works similarly to serving content using custom scheme handler e.g. myapp:// (although scheme handlers are more configurable, see #50). It doesn't require running a server or running additional processes, it just maps requests. Currently scheme handlers are not implemented. There is available the wxpython-response.py example that can be found in README-examples.md and it shows how to use a Resource Handler along with web requests.

Related issues:

54huige commented 6 years ago

Can I set '--enable-file-cookies' ?

cztomczak commented 6 years ago

@54huige You can try. You can pass switches to cef.Initialize, see API ref. According to https://peter.sh/experiments/chromium-command-line-switches/ the --enable-file-cookies flag is not available anymore. It was removed via CR bug #470482: https://bugs.chromium.org/p/chromium/issues/detail?id=470482 .

54huige commented 6 years ago

TypeError: OnDownloadProgress() got an unexpected keyword argument 'web_request'

I have no idea what a mistake this is ?

cztomczak commented 6 years ago

@54huige Please ask questions on the Forum. See API docs and https://github.com/cztomczak/cefpython/blob/master/docs/Migration-guide.md#v553-handlers-callbacks-and-other-interfaces .

54huige commented 6 years ago

@ 54huige请在论坛上提问。请参阅API文档和https://github.com/cztomczak/cefpython/blob/master/docs/Migration-guide.md#v553-handlers-callbacks-and-other-interfaces。

你好 论坛网址多少?

MSusik commented 1 year ago

I would like to learn a bit more about this solution.

Let's say that I have a custom ResourceHandler. In the ProcessRequest method the request comes with http://myapp prefix. How to handle it further?