Kouhei Sutou
null+****@clear*****
Tue Jul 11 23:43:22 JST 2017
Kouhei Sutou 2017-07-11 23:43:22 +0900 (Tue, 11 Jul 2017) New Revision: b0941ac6951766259fa7862962c1e72b84925a9e https://github.com/ranguba/chupa-text-decomposer-webkit/commit/b0941ac6951766259fa7862962c1e72b84925a9e Message: Support proxy Modified files: lib/chupa-text/decomposers/webkit.rb Modified: lib/chupa-text/decomposers/webkit.rb (+22 -1) =================================================================== --- lib/chupa-text/decomposers/webkit.rb 2017-07-11 23:11:35 +0900 (53d2a42) +++ lib/chupa-text/decomposers/webkit.rb 2017-07-11 23:43:22 +0900 (a35f796) @@ -59,7 +59,7 @@ module ChupaText def create_screenshot(data) screenshot = nil - @@view_context ||= WebKit2Gtk::WebContext.new(ephemeral: true) + @@view_context ||= create_view_context view = WebKit2Gtk::WebView.new(context: @@view_context) window = Gtk::OffscreenWindow.new window.set_default_size(800, 600) @@ -88,6 +88,27 @@ module ChupaText status[:screenshot] end + def create_view_context + context = WebKit2Gtk::WebContext.new(ephemeral: true) + http_proxy = ENV["http_proxy"] + https_proxy = ENV["https_proxy"] + ftp_proxy = ENV["ftp_proxy"] + if http_proxy or https_proxy or ftp_proxy + proxy_settings = WebKit2Gtk::NetworkProxySettings.new + if http_proxy + proxy_settings.add_proxy_for_scheme("http", http_proxy) + end + if https_proxy + proxy_settings.add_proxy_for_scheme("https", https_proxy) + end + if ftp_proxy + proxy_settings.add_proxy_for_scheme("ftp", ftp_proxy) + end + context.set_network_proxy_settings(:custom, proxy_settings) + end + context + end + def prepare_screenshot(data, view, status) view.signal_connect("load-changed") do |_, load_event| debug do -------------- next part -------------- HTML����������������������������... Télécharger