Class: Ronin::CLI::HTTPShell Private
- Inherits:
-
Core::CLI::CommandShell
- Object
- Core::CLI::CommandShell
- Ronin::CLI::HTTPShell
- Includes:
- Printing::HTTP
- Defined in:
- lib/ronin/cli/http_shell.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The interactive HTTP shell for the ronin http --shell command.
Instance Attribute Summary collapse
-
#base_url ⇒ URI::HTTP
readonly
private
The base URI.
-
#http ⇒ Ronin::Support::Network::HTTP
readonly
private
The HTTP session.
Instance Method Summary collapse
-
#cd(path) ⇒ Object
private
The
cdshell command. -
#cookie ⇒ Object
private
The
cookieshell command. -
#copy(path, dest) ⇒ Object
private
The
copyshell command. -
#delete(path) ⇒ Object
private
The
deleteshell command. -
#get(path, body = nil) ⇒ Object
private
The
getshell command. -
#head(path) ⇒ Object
private
The
headshell command. -
#headers(subcommand = nil, name = nil, value = nil) ⇒ Object
private
The
set_headershell command. -
#initialize(base_url, **kwargs) ⇒ HTTPShell
constructor
private
Initializes the HTTP Shell.
-
#join(path) ⇒ String
private
Joins the given path with the #base_url.
-
#lock(path) ⇒ Object
private
The
lockshell command. -
#mkcol(path) ⇒ Object
private
The
mkcolshell command. -
#move(path, dest) ⇒ Object
private
The
moveshell command. -
#options(path) ⇒ Object
private
The
optionsshell command. -
#patch(path, body = nil) ⇒ Object
private
The
patchshell command. -
#post(path, body) ⇒ Object
private
The
postshell command. -
#print_response(response) ⇒ Object
private
Prints an HTTP response.
-
#propfind(path) ⇒ Object
private
The
propfindshell command. -
#proppatch(path) ⇒ Object
private
The
proppatchshell command. -
#put(path, body = nil) ⇒ Object
private
The
patchshell command. -
#request(method, path, **kwargs) ⇒ Object
private
Sends an HTTP request.
-
#set_cookie(*params) ⇒ Object
private
The
set-cookieshell command. -
#shell_name ⇒ String
private
The shell prompt name.
-
#trace(path) ⇒ Object
private
The
traceshell command. -
#unlock(path) ⇒ Object
private
The
unlockshell command.
Methods included from Printing::HTTP
#print_body, #print_headers, #print_highlighted_body, #print_last_newline, #print_plain_body, #syntax_lexer_for_content_type
Methods included from Printing::SyntaxHighlighting
#syntax_formatter, #syntax_lexer, #syntax_lexer_for, #syntax_theme
Constructor Details
#initialize(base_url, **kwargs) ⇒ HTTPShell
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the HTTP Shell.
52 53 54 55 56 57 |
# File 'lib/ronin/cli/http_shell.rb', line 52 def initialize(base_url, **kwargs) @base_url = base_url @http = Support::Network::HTTP.connect_uri(@base_url,**kwargs) super() end |
Instance Attribute Details
#base_url ⇒ URI::HTTP (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The base URI.
36 37 38 |
# File 'lib/ronin/cli/http_shell.rb', line 36 def base_url @base_url end |
#http ⇒ Ronin::Support::Network::HTTP (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The HTTP session.
41 42 43 |
# File 'lib/ronin/cli/http_shell.rb', line 41 def http @http end |
Instance Method Details
#cd(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The cd shell command.
76 77 78 |
# File 'lib/ronin/cli/http_shell.rb', line 76 def cd(path) @base_url.path = join(path) end |
#cookie ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The cookie shell command.
318 319 320 321 322 |
# File 'lib/ronin/cli/http_shell.rb', line 318 def if @http. puts @http. end end |
#copy(path, dest) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The copy shell command.
158 159 160 |
# File 'lib/ronin/cli/http_shell.rb', line 158 def copy(path,dest) request(:copy,path, destination: dest) end |
#delete(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The delete shell command.
170 171 172 |
# File 'lib/ronin/cli/http_shell.rb', line 170 def delete(path) request(:delete,path) end |
#get(path, body = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The get shell command.
90 91 92 |
# File 'lib/ronin/cli/http_shell.rb', line 90 def get(path,body=nil) request(:get,path, body: body) end |
#head(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The head shell command.
102 103 104 |
# File 'lib/ronin/cli/http_shell.rb', line 102 def head(path) request(:head,path) end |
#headers(subcommand = nil, name = nil, value = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The set_header shell command.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/ronin/cli/http_shell.rb', line 286 def headers(subcommand=nil,name=nil,value=nil) case subcommand when 'set' if (name && value) @http.headers[name] = value else puts "headers: must specify both NAME and VALUE arguments" end when 'unset' if name @http.headers.delete(name) else puts "headers: must specify NAME argument" end when nil unless @http.headers.empty? @http.headers.each do |name,value| puts "#{colors.bold(name)}: #{value}" end else puts "No request headers set" end else puts "headers: unknown sub-command: #{subcommand.inspect}" end end |
#join(path) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Joins the given path with the #base_url.
347 348 349 350 351 352 353 |
# File 'lib/ronin/cli/http_shell.rb', line 347 def join(path) if path.start_with?('/') path else File.(File.join(@base_url.path,path)) end end |
#lock(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The lock shell command.
182 183 184 |
# File 'lib/ronin/cli/http_shell.rb', line 182 def lock(path) request(:lock,path) end |
#mkcol(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The mkcol shell command.
206 207 208 |
# File 'lib/ronin/cli/http_shell.rb', line 206 def mkcol(path) request(:mkcol,path) end |
#move(path, dest) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The move shell command.
220 221 222 |
# File 'lib/ronin/cli/http_shell.rb', line 220 def move(path,dest) request(:move,path, destination: dest) end |
#options(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The options shell command.
194 195 196 |
# File 'lib/ronin/cli/http_shell.rb', line 194 def (path) request(:options,path) end |
#patch(path, body = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The patch shell command.
116 117 118 |
# File 'lib/ronin/cli/http_shell.rb', line 116 def patch(path,body=nil) request(:patch,path, body: body) end |
#post(path, body) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The post shell command.
130 131 132 |
# File 'lib/ronin/cli/http_shell.rb', line 130 def post(path,body) request(:post,path, body: body) end |
#print_response(response) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Prints an HTTP response.
384 385 386 |
# File 'lib/ronin/cli/http_shell.rb', line 384 def print_response(response) super(response, show_headers: true) end |
#propfind(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The propfind shell command.
232 233 234 |
# File 'lib/ronin/cli/http_shell.rb', line 232 def propfind(path) request(:propfind,path) end |
#proppatch(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The proppatch shell command.
243 244 245 |
# File 'lib/ronin/cli/http_shell.rb', line 243 def proppatch(path) request(:proppatch,path) end |
#put(path, body = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The patch shell command.
144 145 146 |
# File 'lib/ronin/cli/http_shell.rb', line 144 def put(path,body=nil) request(:put,path, body: body) end |
#request(method, path, **kwargs) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sends an HTTP request.
368 369 370 371 372 373 374 |
# File 'lib/ronin/cli/http_shell.rb', line 368 def request(method,path,**kwargs) path = join(path) @http.request(method,path,**kwargs) do |response| print_response(response) end end |
#set_cookie(*params) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The set-cookie shell command.
334 335 336 |
# File 'lib/ronin/cli/http_shell.rb', line 334 def (*params) @http. = params.join(' ') end |
#shell_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The shell prompt name.
64 65 66 |
# File 'lib/ronin/cli/http_shell.rb', line 64 def shell_name "#{@base_url}" end |
#trace(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The trace shell command.
255 256 257 |
# File 'lib/ronin/cli/http_shell.rb', line 255 def trace(path) request(:trace,path) end |
#unlock(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The unlock shell command.
267 268 269 |
# File 'lib/ronin/cli/http_shell.rb', line 267 def unlock(path) request(:unlock,path) end |