Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert how to get the stat code from ...

Replytotopic

how to get the stat code from the header of repsonse

Posted in Forums : Ask a Rails expert

 
Profile

Authority 0
Posting Rating 22
Sign in to rate this post

My code is as follows client = HTTPClient.new response= client.get(‘http://localhost:3000/’)
My response header is as follows
client.get(‘http://localhost:3000/’)= #<http::message:0x537e290> @peer_cert = nil @header = #<http::message::headers:0x537e27c> @request_via_proxy = nil @response_status_code = 200 @body_charset = nil @request_query = nil @http_version = 1.1 @header_item = Array (6 element(s)) @request_method = nil @body_type = nil @request_uri = nil @chunked = false @body_date = nil @is_request = false @reason_phrase = OK @body_size = 0 StatusCodeMap = Hash (12 element(s)) CharsetMap = Hash (4 element(s)) @body = #<http::message::body:0x537e268> @@mime_type_func = nil Headers = HTTP::Message::Headers @inheritable_attributes = Empty Hash @@attr_internal_naming_format = @_%s CRLF = Body = HTTP::Message::Body

My requirement is to read the @response_status_code from the above header .Please give me some idea about this.
Thanks in advance.

 
Profile

Authority 12
Posting Rating 96
Sign in to rate this post

Hi,

client = HTTPClient.new

=> [...]

response = client.get “http://google.com”

=> [...]

response.status

=> 301

response.reason

=> “Moved Permanently”

Jon

Replytotopic

Other Recent Topics

Ask a Rails expert : Tracking down an issue

Ask a Rails expert : Thread Vs Transaction

Ask a Rails expert : implementing whitelist plugin

Ask a Rails expert : Validation helper

Ask a Rails expert : FILE EDIT/DELETE

Ask a Rails expert : decrypting the password

Ask a Rails expert : Static Objects in Rails

Ask a Rails expert : Newbie - Rake Cant Execute Test

Ask a Rails expert : Call Web service

Ask a Rails expert : RMagick issues

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel