Class: Baykit::BayServer::Docker::Ajp::Command::CmdSendHeaders
- Inherits:
-
AjpCommand
- Object
- Protocol::Command
- AjpCommand
- Baykit::BayServer::Docker::Ajp::Command::CmdSendHeaders
- Includes:
- Util
- Defined in:
- lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb
Class Attribute Summary collapse
-
.well_known_header_map ⇒ Object
readonly
Returns the value of attribute well_known_header_map.
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Attributes inherited from AjpCommand
Class Method Summary collapse
Instance Method Summary collapse
- #add_header(name, value) ⇒ Object
- #get_header(name) ⇒ Object
- #handle(handler) ⇒ Object
-
#initialize ⇒ CmdSendHeaders
constructor
A new instance of CmdSendHeaders.
- #pack(pkt) ⇒ Object
- #to_s ⇒ Object
- #unpack(pkt) ⇒ Object
Methods inherited from AjpCommand
Constructor Details
#initialize ⇒ CmdSendHeaders
Returns a new instance of CmdSendHeaders.
61 62 63 64 65 66 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 61 def initialize super(AjpType::SEND_HEADERS, false) @headers = {} @status = HttpStatus::OK @desc = nil end |
Class Attribute Details
.well_known_header_map ⇒ Object (readonly)
Returns the value of attribute well_known_header_map.
31 32 33 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 31 def well_known_header_map @well_known_header_map end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
59 60 61 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 59 def desc @desc end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
57 58 59 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 57 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
58 59 60 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 58 def status @status end |
Class Method Details
.get_well_known_header_name(code) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 48 def self.get_well_known_header_name(code) @well_known_header_map.keys.each do |name| if @well_known_header_map[name] == code return name end end return nil end |
Instance Method Details
#add_header(name, value) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 138 def add_header(name, value) values = @headers[name] if values == nil values = [] @headers[name] = values end values.append(value) end |
#get_header(name) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 129 def get_header(name) values = @headers[name.downcase] if values == nil || values.empty? nil else values[0] end end |
#handle(handler) ⇒ Object
124 125 126 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 124 def handle(handler) return handler.handle_send_headers(self) end |
#pack(pkt) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 72 def pack(pkt) acc = pkt.new_ajp_data_accessor acc.put_byte(@type) acc.put_short(@status) acc.put_string(HttpStatus.description(@status)) count = 0 @headers.keys.each do |key| count += @headers[key].length end acc.put_short(count) @headers.keys.each do |name| code = CmdSendHeaders.well_known_header_map[name] @headers[name].each do |value| if code != nil acc.put_short(code) else acc.put_string(name) end acc.put_string(value) end end # must be called from last line super end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 68 def to_s() return "SendHeaders(s=#{@status} d=#{@desc} h=#{@headers}" end |
#unpack(pkt) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/baykit/bayserver/docker/ajp/command/cmd_send_headers.rb', line 101 def unpack(pkt) acc = pkt.new_ajp_data_accessor prefix_code = acc.get_byte if prefix_code != AjpType::SEND_HEADERS raise ProtocolException.new "Expected SEND_HEADERS" end @status = acc.get_short @desc = acc.get_string count = acc.get_short count.times do |i| code = acc.get_short name = CmdSendHeaders.get_well_known_header_name(code) if name == nil name = acc.get_string_by_len(code) end value = acc.get_string add_header(name, value) end #BayLog.info("%s", self) end |