Skip to content

Commit 35db457

Browse files
authored
Merge pull request #423 from etg-lt/pr-ua
User-Agen 設定の追加
2 parents 146c5ba + 4f7be53 commit 35db457

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/command/setting.rb

+4
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,10 @@ def self.get_setting_tab_info
534534
"エラーは出ないが読めなくなる)",
535535
tab: :detail
536536
},
537+
"user-agent" => {
538+
type: :string, help: "User-Agent 設定\n未指定時 Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
539+
tab: :detail
540+
},
537541
"webui.theme" => {
538542
type: :select, help: "WEB UI 用テーマ選択",
539543
invisible: true,

lib/extension.rb

+3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66

77
require "open-uri"
88
require "openssl"
9+
require_relative "inventory"
910

1011
# open-uri で http → https へのリダイレクトを有効にする
1112
require "open_uri_redirections"
1213

1314
# open-uri に渡すオプションを生成(必要に応じて extensions/*.rb でオーバーライドする)
1415
def make_open_uri_options(add)
16+
ua = Inventory.load("local_setting")["user-agent"] || "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
1517
add.merge(ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
18+
add.merge("User-Agent" => ua)
1619
end
1720

1821
#

0 commit comments

Comments
 (0)