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

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

.categoryObject

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



10
11
12
# File 'lib/htty/cli/commands/headers_response.rb', line 10

def self.category
  'Inspecting Responses'
end

.command_lineObject

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



16
17
18
# File 'lib/htty/cli/commands/headers_response.rb', line 16

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

.helpObject

Returns the help text for the headers-response command.



21
22
23
# File 'lib/htty/cli/commands/headers_response.rb', line 21

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

.help_extendedObject

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



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

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

.see_also_commandsObject

Returns related command classes for the headers-response command.



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

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

#performObject

Performs the headers-response command.



44
45
46
47
48
49
50
51
# File 'lib/htty/cli/commands/headers_response.rb', line 44

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