Class: FileStore::WebDAV::ResponseHeaders

Inherits:
Object
  • Object
show all
Defined in:
lib/filestore/webdav/webdav.rb

Overview

Class implementing easy accessor to HTTP response headers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ ResponseHeaders

Initialize new ResponseHeaders instance

Arguments:

text: The raw response text


25
26
27
28
29
30
31
32
# File 'lib/filestore/webdav/webdav.rb', line 25

def initialize(text)
  @headers = {}
  @http_version = ''
  @status = -1
  @response_text = ''
  
  parse text
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



18
19
20
# File 'lib/filestore/webdav/webdav.rb', line 18

def headers
  @headers
end

#http_versionObject (readonly)

Returns the value of attribute http_version.



18
19
20
# File 'lib/filestore/webdav/webdav.rb', line 18

def http_version
  @http_version
end

#response_textObject (readonly)

Returns the value of attribute response_text.



18
19
20
# File 'lib/filestore/webdav/webdav.rb', line 18

def response_text
  @response_text
end

#statusObject (readonly)

Returns the value of attribute status.



18
19
20
# File 'lib/filestore/webdav/webdav.rb', line 18

def status
  @status
end

Instance Method Details

#is_html?Boolean

Determines wether the reponse body is HTML

Returns:

true if content type is appilcation/html, false otherwise

Returns:

  • (Boolean)


48
49
50
# File 'lib/filestore/webdav/webdav.rb', line 48

def is_html?
  not (@headers['Content-Type'] =~ /^application\/html.*/).nil?
end

#is_xml?Boolean

Determines wether the reponse body is XML

Returns:

true if content type is appilcation/xml, false otherwise

Returns:

  • (Boolean)


39
40
41
# File 'lib/filestore/webdav/webdav.rb', line 39

def is_xml?
  not (@headers['Content-Type'] =~ /^application\/xml.*/).nil?
end