module Ronin::CLI::Printing::HTTP

Common methods for {Commands::Http} and {HTTPShell}.

Public Instance Methods

print_body(response) click to toggle source

Prints the response body.

@param [Net::HTTPResponse] response

The HTTP response object.
print_headers(response) click to toggle source

Prints the response headers.

@param [Net::HTTPResponse] response

The HTTP response object.
print_highlighted_body(response) click to toggle source

Prints a syntax highlighted response body.

@param [Net::HTTPResponse] response

The HTTP response object.
print_last_newline(text) click to toggle source

Ensures that a final new-line is printed after the given text.

@param [String] text

The previous text that was printed.
print_plain_body(response) click to toggle source

Prints a plain unhighlighted response body.

@param [Net::HTTPResponse] response

The HTTP response object.
print_response(response, show_headers: nil) click to toggle source

Prints the response.

@param [Net::HTTPResponse] response

The HTTP response object.

@param [Boolean] show_headers

Controls whether the response headers are printed.
syntax_lexer_for_content_type(content_type) click to toggle source

Returns the syntax lexer for the given ‘Content-Type` header.

@param [String, nil] content_type

The HTTP `Content-Type` header value.

@return [Rouge::Lexers::HTML,

       Rouge::Lexers::XML,
       Rouge::Lexers::JavaScript,
       Rouge::Lexers::JSON,
       Rouge::Lexers::PlainText]
The specific syntax lexer or `nil` if the `Content-Type` was not
recognized.
# File lib/ronin/cli/printing/http.rb, line 74
def syntax_lexer_for_content_type(content_type)
  mimetype = content_type && content_type.sub(/;.*$/,'')

  syntax_lexer_for(mimetype: mimetype)
end