From 1d9659309bcb112b9d7761153444767b3ca6ead0 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Sat, 24 Feb 2024 12:01:29 +0800 Subject: [PATCH] Allow customizing User-Agent header (HTTP only). --- lib/proxifier/proxies/http.rb | 1 + lib/proxifier/proxy.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/proxifier/proxies/http.rb b/lib/proxifier/proxies/http.rb index 4e0c856..da1cbd7 100644 --- a/lib/proxifier/proxies/http.rb +++ b/lib/proxifier/proxies/http.rb @@ -9,6 +9,7 @@ module Proxifier socket << "CONNECT #{host}:#{port} HTTP/1.1\r\n" socket << "Host: #{host}:#{port}\r\n" socket << "Proxy-Authorization: Basic #{["#{user}:#{password}"].pack("m").chomp}\r\n" if user + socket << "User-Agent: #{user_agent}\r\n" if user_agent socket << "\r\n" buffer = Net::BufferedIO.new(socket) diff --git a/lib/proxifier/proxy.rb b/lib/proxifier/proxy.rb index 4b75fab..5251a8b 100644 --- a/lib/proxifier/proxy.rb +++ b/lib/proxifier/proxy.rb @@ -51,7 +51,7 @@ module Proxifier @query_options ||= query ? Hash[query.split("&").map { |q| q.split("=") }] : {} end - %w(no_proxy).each do |option| + %w(no_proxy user_agent).each do |option| class_eval "def #{option}; options[:#{option}] end" end