Allow customizing User-Agent header (HTTP only).
This commit is contained in:
parent
bf1f0bee18
commit
1d9659309b
|
@ -9,6 +9,7 @@ module Proxifier
|
||||||
socket << "CONNECT #{host}:#{port} HTTP/1.1\r\n"
|
socket << "CONNECT #{host}:#{port} HTTP/1.1\r\n"
|
||||||
socket << "Host: #{host}:#{port}\r\n"
|
socket << "Host: #{host}:#{port}\r\n"
|
||||||
socket << "Proxy-Authorization: Basic #{["#{user}:#{password}"].pack("m").chomp}\r\n" if user
|
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"
|
socket << "\r\n"
|
||||||
|
|
||||||
buffer = Net::BufferedIO.new(socket)
|
buffer = Net::BufferedIO.new(socket)
|
||||||
|
|
|
@ -51,7 +51,7 @@ module Proxifier
|
||||||
@query_options ||= query ? Hash[query.split("&").map { |q| q.split("=") }] : {}
|
@query_options ||= query ? Hash[query.split("&").map { |q| q.split("=") }] : {}
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(no_proxy).each do |option|
|
%w(no_proxy user_agent).each do |option|
|
||||||
class_eval "def #{option}; options[:#{option}] end"
|
class_eval "def #{option}; options[:#{option}] end"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue