123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::Http::Response

Relationships
Inherits: Object

Overview

Response objects allows you to get the response information from the server, you can only receive the Response if you have attached a callback block when calling start from the Request object.

Version:

  • SketchUp 2017

Instance Method Summary

  • #body ⇒ String

    Gets the http body that was received from the server as a string encoded using the charset provided in the Content-Type of the server response, if no charset is specified, ASCII-8BIT will be used.

  • #headers ⇒ Hash

    Returns the http headers that were sent by the server.

  • #status_code ⇒ Integer

    Returns the HTTP response status code as defined in rfc2616.

Instance Method Details

#bodyString

Gets the http body that was received from the server as a string encoded using the charset provided in the Content-Type of the server response, if no charset is specified, ASCII-8BIT will be used.

Examples:

@request = Sketchup::Http::Request.new("http://localhost:8080")

@request.start do |request, response|
  puts "body: " + response.body
end

Version:

  • SketchUp 2017

#headersHash

Returns the http headers that were sent by the server.

Examples:

@request = Sketchup::Http::Request.new("http://localhost:8080")

@request.start do |request, response|
  response.headers.each do |key, value|
    puts "#{key}: #{value}"
  end
end

Version:

  • SketchUp 2017

#status_codeInteger

Returns the HTTP response status code as defined in rfc2616.

Examples:

@request = Sketchup::Http::Request.new("http://localhost:8080")

@request.start do |request, response|
  puts "http status code: #{response.status_code}"
end

Version:

  • SketchUp 2017