Redirecting Request (nsiHttpChannel?) in Firefox Extensions

We can do this by overriding the nsiHttpChannel with a new one, doing this is slightly complicated but luckily the add-on https-everywhere implements this to force a https connection. https-everywhere‘s source code is available here Most of the code needed for this is in the files [IO Util.js] [ChannelReplacement.js] We can work with the above … Read more

Setting a cookie using JavaFX’s WebEngine/WebView

I have managed to solve this issue with the help of Vasiliy Baranov from Oracle. Vasiliy wrote to me: Try putting the cookie into java.net.CookieHandler.getDefault() after the WebView is instantiated for the first time and before the call to WebEngine.load, e.g. as follows: WebView webView = new WebView(); URI uri = URI.create(“http://mysite.com”); Map<String, List<String>> headers … Read more

Putting a `Cookie` in a `CookieJar`

Old versions of the Requests library (0.14.2 and older) put new cookies in the jar for you when you pass a CookieJar object: import requests import cookielib URL = ‘…whatever…’ jar = cookielib.CookieJar() r = requests.get(URL, cookies=jar) r = requests.get(URL, cookies=jar) The first request to the URL fills the jar and the second request sends … Read more

How to get host name with port from a http or https request

You can use HttpServletRequest.getScheme() to retrieve either “http” or “https”. Using it along with HttpServletRequest.getServerName() should be enough to rebuild the portion of the URL you need. You don’t need to explicitly put the port in the URL if you’re using the standard ones (80 for http and 443 for https). Edit: If your servlet … Read more

How to set custom http headers when changing iframe src?

You can have the results of an ajax request that has custom headers be set as the content of an iframe like so: $.ajax({ type: “GET”, url: “https://app.icontact.com/icp/a/”, contentType: “application/json”, beforeSend: function(xhr, settings){ xhr.setRequestHeader(“some_custom_header”, “foo”);}, success: function(data){ $(“#output_iframe_id”).attr(‘src’,”data:text/html;charset=utf-8,” + escape(data)) } }); This is assuming the iframe is pointing at a cross domain src. It … Read more

Removing a Given Key from a Groovy Map

req.getParameterMap returns an immutable map which cannot be modified. You need to create a new map, putAll from the parameter map and remove the required key you do not want. def reqParams = [:] << req.getParameterMap() reqParams.remove(‘blah’) You have your new map as reqParams (without the undesired key value pair) and the original parameter map.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)