Class: HTTY::CLI::Commands::HeadersResponse

Inherits:
HTTY::CLI::Command show all
Includes:
Display
Defined in:
lib/htty/cli/commands/headers_response.rb

Overview

Encapsulates the headers-response command.

Constant Summary

Constant Summary

Constants included from Display

Display::FORMATS

Instance Attribute Summary

Attributes inherited from HTTY::CLI::Command

#arguments, #session

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Display

#break, #format, #formatted_prompt_for, #indent, #logotype, #normal, #notice, #pluralize, #rescuing_from, #say, #say_goodbye, #say_header, #say_hello, #show_headers, #show_request, #show_response, #strong, #word_wrap, #word_wrap_indented

Methods inherited from HTTY::CLI::Command

#add_request_if_new, alias_for, aliases, build_for, command_line_arguments, complete_for?, #initialize, notify_if_cookies_cleared, raw_name, sanitize_arguments

Constructor Details

This class inherits a constructor from HTTY::CLI::Command

Class Method Details

+ (Object) category

Returns the name of a category under which help for the headers-response command should appear.



24
25
26
# File 'lib/htty/cli/commands/headers_response.rb', line 24

def self.category
  'Inspecting Responses'
end

+ (Object) command_line

Returns the string used to invoke the headers-response command from the command line.



30
31
32
# File 'lib/htty/cli/commands/headers_response.rb', line 30

def self.command_line
  'headers[-response]'
end

+ (Object) help

Returns the help text for the headers-response command.



35
36
37
# File 'lib/htty/cli/commands/headers_response.rb', line 35

def self.help
  'Displays the headers of the response'
end

+ (Object) help_extended

Returns the extended help text for the headers-response command.



40
41
42
43
44
45
46
# File 'lib/htty/cli/commands/headers_response.rb', line 40

def self.help_extended
  'Displays the headers received in the response. Does not communicate ' +
  "with the host.\n"                                                     +
  "\n"                                                                   +
  "A '#{HTTY::Response::COOKIES_HEADER_NAME}' request header is marked " +
  'with a bold asterisk (it looks like a cookie).'
end

+ (Object) see_also_commands

Returns related command classes for the headers-response command.



49
50
51
52
53
54
55
# File 'lib/htty/cli/commands/headers_response.rb', line 49

def self.see_also_commands
  [HTTY::CLI::Commands::BodyResponse,
   HTTY::CLI::Commands::Cookies,
   HTTY::CLI::Commands::CookiesUse,
   HTTY::CLI::Commands::Status,
   HTTY::CLI::Commands::HeadersRequest]
end

Instance Method Details

- (Object) perform

Performs the headers-response command.



58
59
60
61
62
63
64
65
# File 'lib/htty/cli/commands/headers_response.rb', line 58

def perform
  unless (response = session.last_response)
    raise HTTY::NoResponseError
  end
  show_headers response.headers,
               :show_asterisk_next_to => HTTY::Response::COOKIES_HEADER_NAME
  self
end