Is it possible to override the HTTP functions in wxHtmlWindow? - wxwidgets

I would like wxHtmlWindow to use libcurl instead of the internal wxHTTP class.
Is there an easy way to do this? If not, can I at least change the useragent wxHtmlWindow sends when it accesses pages?

I would create a class that manage my curl session. Setting a user agent, cookies, server to connect to etc.
Also I would make that class to be able to save the page I get from the internet to a file temp/web.htm
and then I would use something like:
htmlwin->LoadPage("temp/web.htm");
Where htmlwin is a wxHtmlWindow
This is the first thing that comes in my mind, maybe I can think to a better solution.
EDIT 1:
See this link so see a little example of wrapping curl in a C++ class

Related

Request URI too long on spartacus services

I've been trying to make use of service.getNavigation() method, but apparently the Request URI is too long which causes this error:
Request-URI Too Long
The requested URL's length exceeds the capacity limit for this server.
Is there a spartacus config that can resolve this issue?
Or is this supposed to be handled in the cloud (ccv2) config?
Not sure which service are you talking about specifically and what data are you passing there. For starters, please read this: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414
Additionally it would benefit everyone if you could say something about the service you're using and the data you are trying to pass/get.
The navigation component is firing a request for all componentIds. If you have a navigation with a lot of (root?) elements, the maximum length of HTTP GET request might be too long for the given client or server.
The initial implementation of loading components was actually done by a POST request, but the impression was that we would not need to support requests with so many components. I guess we were wrong.
Luckily, the legacy POST based request is still in the code base, it's OccCmsComponentAdapter.findComponentsByIdsLegacy.
The easiest way for you to use this code, is to provide a CustomOccCmsComponentAdapter, that extends from OccCmsComponentAdapter. Then you can override the findComponentsByIds method and simply call the super.findComponentsByIdsLegacy and pass in a copy of the arguments.
A more cleaner way would be to override the CmsComponentConnector and directly delegate the load to the adapter.findComponentsByIdsLegacy. I would not start here, as it's more complicated. Do a POC with the first suggested approach.

Quickly-editable config file, not visible to public visitors?

I am in the middle of working with, and getting a handle on Vuejs. I would like to code my app in a way that it has some configurable behaviors, so that I could play with parameter values, like you do when you edit your Sublime preferences, but without having to compile my app again. Ideally, I would want a situation where I could have my colleagues be able to fiddle with settings all day long, by editing a file over FTP maybe, or over some interface....
The only way I know how to do it now, is to place those settings in a separate file, but as the app runs in the client, that file would have to be fetched via another HTTP request, meaning it's a publicly readable file. Even though there isn't any sensitive information in such a configuration file, I still feel a little wonky about having it public like that, if it can be avoided in any way...
Can it be avoided?
I dont think you can avoid this. One way or another your config file will be loaded into the vuejs application, therefore being visible to the end user (with some effort).
Even putting the file outside of the public folder wouldnt help you much, because then it is unavailable for HTTP to request the file. It would only be available to your compile process in this case.
So a possible solution could be to have some sort of HTTP request that requests GET example.com/settings and returns you a JSON object. Then you could have your app make a cookie like config_key = H47DXHJK12 (or better a UUID https://en.wikipedia.org/wiki/Universally_unique_identifier) which would be the access key for a specific config object.
Your application must then request GET example.com/settings (which should send the config_key cookie), and your config object for this secret key will be returned. If the user clears his cookies, a new request will return an empty config.

OmniPay manually "create" a response class?

So I'm using https://github.com/thephpleague/omnipay-mollie and I've decided to use webhooks instead of the example they have on their readme. I've got all that working but when it comes time to process the webhook, I was hoping to have access to the helper functions such as isPending, isRefunded, etc...
However, because this hasn't been put into the AbstractResponse class, they aren't available. Usually, OmniPay lets you use a method called acceptNotification() that parses the request and puts it into an AbstractResponse class so that you can use these helper methods.
Problem is, for whatever reason, omnipay-mollie doesn't allow you to use this function. So I'm stuck trying to find a way to manually force my webhook request into this AbstractClass so that I can use these helper functions. I've dug around the entire OmniPay and OmniPay-Mollie source code and cannot find any sort of way to instantiate the class or anything like that.
Hopefully someone with more experience can lend a hand.

Yii load system params from Database using Active Record

I am interested in loading some system params into the Yii::app()->params array from the database using a CActiveRecord extension called SiteSetting.
Unfortunately I couldn't find much advice online for this, but believe I can place a method in SiteSetting called loadSiteSettingsToAppParams and add the setting...
'onBeginRequest'=>array('SiteSetting', 'loadSiteSettingsToAppParams')
...to the config.
I would like to know if I can only add this onBeginRequest to the Yii::app() somewhere within the SiteSetting class (to keep my code modular) and whether this is a sensible approach.
Thanks in advance.
Just re-read your question now and I'd try to provide answers.
To the question "I would like to know if I can only add this onBeginRequest to the Yii::app() somewhere within the SiteSetting class (to keep my code modular)": the answer is, You're not restricted to just a Class. You could (theoretically) place it anywhere within your application and also in the config.php file.
As to whether it's a sensible approach, it depends on the time it would take to request those settings from the database and whether you're prepared to add that time to your HttpRequest response time. The onBeforeRequest is fired before every HttpRequest and if the loadSiteSettingsToAppParams method consumes lots of time, you're adding that time to your HttpRequest response time.
I'd advise that you fetch those settings once after login and then update them only when they change (the settings are updated). This way, you could place the call to loadSiteSettingsToAppParams in the UserIdentity class and call it after a successful login.
That's just how I'd go about doing this though.
Hope I helped.
The easy & nice way to accomplish this by using a comoponent like SettingComoponent and place in the components directory protected/components then pre load this component in the preload section like this preload => array('log', 'setting', ...). That's it and now you can call this component anywhere you want like Yii:app()->setting->whatever.
I hope this is answer can be useful for you.

Get RESTAdapter host

RESTAdapter has the possibility to specify a url for the backend:
DS.RESTAdapter.reopen({
url: 'https://api.example.com'
});
How can I access this property programmatically? I mean something like: DS.RESTAdapter.get('url') <-This doesn't work
You're setting the properties on the class not the instance, thats why you can't retrieve the values. There are two possible solutions.
You can get the values from the prototype
DS.RESTAdapter.prototype.url
or you can instantiate the class and get it from there
DS.RESTAdapter.create().url
Quick and dirty ...
NOTE: Please use only for debugging, this API is intern and will cenrtainly change in the future, so don't rely on it.
Assuming you have only one Store in your application:
App.__container__.lookup('store:main').get('adapter.url')
If you are using Chrome Dev Tools you can try to call this from the console, it should print out the url used by the default adapter used by the default Store.
But it's discouraged to be used for other then for debugging.
Hope it helps
Or
DS.defaultStore.adapter.url