/usr/bin/httpclient is in ruby-httpclient 2.3.3-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #!/usr/bin/env ruby
# httpclient shell command.
#
# Usage: 1) % httpclient get https://www.google.co.jp/ q=ruby
# Usage: 2) % httpclient
#
# For 1) it issues a GET request to the given URI and shows the wiredump and
# the parsed result. For 2) it invokes irb shell with the binding that has a
# HTTPClient as 'self'. You can call HTTPClient instance methods like;
# > get "https://www.google.co.jp/", :q => :ruby
require 'httpclient'
METHODS = ['head', 'get', 'post', 'put', 'delete', 'options', 'propfind', 'proppatch', 'trace']
if ARGV.size >= 2 && METHODS.include?(ARGV[0])
client = HTTPClient.new
client.debug_dev = STDERR
$DEBUG = true
require 'pp'
pp client.send(*ARGV)
exit
end
require 'irb'
require 'irb/completion'
class Runner
def initialize
@httpclient = HTTPClient.new
end
def method_missing(msg, *a, &b)
debug, $DEBUG = $DEBUG, true
begin
@httpclient.send(msg, *a, &b)
ensure
$DEBUG = debug
end
end
def run
IRB.setup(nil)
ws = IRB::WorkSpace.new(binding)
irb = IRB::Irb.new(ws)
IRB.conf[:MAIN_CONTEXT] = irb.context
trap("SIGINT") do
irb.signal_handle
end
begin
catch(:IRB_EXIT) do
irb.eval_input
end
ensure
IRB.irb_at_exit
end
end
def to_s
'HTTPClient'
end
end
Runner.new.run
|