Class: Knj::Http2::Response

Inherits:
Object show all
Defined in:
lib/knj/http2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Response

Returns a new instance of Response.



416
417
418
419
420
# File 'lib/knj/http2.rb', line 416

def initialize(args = {})
  @args = args
  @args[:headers] = {} if !@args.key?(:headers)
  @args[:body] = "" if !@args.key?(:body)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



414
415
416
# File 'lib/knj/http2.rb', line 414

def args
  @args
end

Instance Method Details

#bodyObject



444
445
446
# File 'lib/knj/http2.rb', line 444

def body
  return @args[:body]
end

#charsetObject



448
449
450
# File 'lib/knj/http2.rb', line 448

def charset
  return @args[:charset]
end

#codeObject



436
437
438
# File 'lib/knj/http2.rb', line 436

def code
  return @args[:code]
end

#contenttypeObject



452
453
454
# File 'lib/knj/http2.rb', line 452

def contenttype
  return @args[:contenttype]
end

#header(key) ⇒ Object



426
427
428
429
# File 'lib/knj/http2.rb', line 426

def header(key)
  return false if !@args[:headers].key?(key)
  return @args[:headers][key].first.to_s
end

#header?(key) ⇒ Boolean

Returns:

  • (Boolean)


431
432
433
434
# File 'lib/knj/http2.rb', line 431

def header?(key)
  return true if @args[:headers].key?(key) and @args[:headers][key].first.to_s.length > 0
  return false
end

#headersObject



422
423
424
# File 'lib/knj/http2.rb', line 422

def headers
  return @args[:headers]
end

#http_versionObject



440
441
442
# File 'lib/knj/http2.rb', line 440

def http_version
  return @args[:http_version]
end