bayserver-docker-http 2.3.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ac8ae113853e42ea44b42f459d91cd55c337e02bcb5726de6481febf07444e2
4
- data.tar.gz: '0992bd7b3b0d38c3e0ecbd5d0f81e16035a09e5b7485fc0a0f85a86acfc4cdb3'
3
+ metadata.gz: 5a10c4b80275616d87322d82542025717b59c82bc6aadc73098f69ca63f63563
4
+ data.tar.gz: d26694ce403eb65e1a7b365d4905a116ab7d93b4b2c2dea7946476bc0258d2f9
5
5
  SHA512:
6
- metadata.gz: d8c20c52306a2edeb7b05f860d4a4d44e8bd6e4a619007632f38731a107dd8eddfdcb0bf8f08898417690dff9b8e9b015c9e38c425d0c176037dd4349580e470
7
- data.tar.gz: a797d4f137a00a9d7f8c643bc51dfbcf1be6c55a8d44afde1a827a4cb709f31356c18b98f2de9732c9b40017d3d7cf6d6871e48c0fe7c7ac0f05907a5d46c416
6
+ metadata.gz: 780e7922748b59d7a426d9aa4d6d89db81fe68ccd58dd09a43b620c504500fe14a5a5344ffd05d28fefc2f64df46374a3210eb2b96416ef0982a9ae4ccbc3c5b
7
+ data.tar.gz: 48b2750d675a6a8df7a11f60f4e9d43c45c17970360d47a2c90cb66aa1fc5f3f00f346bb7bad9dfd27b4db8b46cc34807231194b7ea316ab85c6424177cc7067
@@ -46,7 +46,7 @@ module Baykit
46
46
  end
47
47
 
48
48
  def finished()
49
- return @cmd_handler.finished()
49
+ return @cmd_handler.req_finished()
50
50
  end
51
51
  end
52
52
  end
@@ -0,0 +1,16 @@
1
+
2
+ module Baykit
3
+ module BayServer
4
+ module Docker
5
+ module Http
6
+ module H1
7
+ module H1Handler # interface
8
+ def on_protocol_error(e)
9
+ raise NotImplementedError.new
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,6 +1,7 @@
1
+ require 'openssl'
1
2
  require 'baykit/bayserver/agent/upgrade_exception'
2
3
 
3
- require 'baykit/bayserver/docker/base/inbound_handler'
4
+ require 'baykit/bayserver/common/inbound_handler'
4
5
 
5
6
  require 'baykit/bayserver/protocol/package'
6
7
  require 'baykit/bayserver/tours/req_content_handler'
@@ -10,7 +11,13 @@ require 'baykit/bayserver/util/url_encoder'
10
11
  require 'baykit/bayserver/util/http_util'
11
12
  require 'baykit/bayserver/util/headers'
12
13
 
14
+ require 'baykit/bayserver/protocol/packet_packer'
15
+ require 'baykit/bayserver/protocol/command_packer'
16
+
17
+ require 'baykit/bayserver/docker/http/h1/h1_handler'
13
18
  require 'baykit/bayserver/docker/http/h1/h1_command_handler'
19
+ require 'baykit/bayserver/docker/http/h1/h1_command_unpacker'
20
+ require 'baykit/bayserver/docker/http/h1/h1_packet_unpacker'
14
21
  require 'baykit/bayserver/docker/http/h1/h1_protocol_handler'
15
22
  require 'baykit/bayserver/docker/http/h2/package'
16
23
 
@@ -19,22 +26,36 @@ module Baykit
19
26
  module Docker
20
27
  module Http
21
28
  module H1
22
- class H1InboundHandler < Baykit::BayServer::Docker::Http::H1::H1ProtocolHandler
29
+ class H1InboundHandler
23
30
 
24
31
  class InboundProtocolHandlerFactory
25
32
  include Baykit::BayServer::Protocol::ProtocolHandlerFactory # implements
26
33
 
34
+ include Baykit::BayServer::Protocol
35
+
27
36
  def create_protocol_handler(pkt_store)
28
- return H1InboundHandler.new(pkt_store)
37
+ ib_handler = H1InboundHandler.new
38
+ cmd_unpacker = H1CommandUnPacker.new(ib_handler, true)
39
+ pkt_unpacker = H1PacketUnPacker.new(cmd_unpacker, pkt_store)
40
+ pkt_packer = PacketPacker.new
41
+ cmd_packer = CommandPacker.new(pkt_packer, pkt_store)
42
+
43
+ proto_handler = H1ProtocolHandler.new(ib_handler, pkt_unpacker, pkt_packer, cmd_unpacker, cmd_packer, true)
44
+ ib_handler.init(proto_handler)
45
+ return proto_handler
29
46
  end
30
47
  end
31
48
 
32
- include Baykit::BayServer::Docker::Base::InboundHandler # implements
49
+ include Baykit::BayServer::Common::InboundHandler # implements
50
+ include H1Handler # implements
51
+
33
52
  include Baykit::BayServer::Agent
34
53
  include Baykit::BayServer::Protocol
35
54
  include Baykit::BayServer::Tours
36
55
  include Baykit::BayServer::Util
56
+ include Baykit::BayServer::Docker::Http::H1::Command
37
57
  include Baykit::BayServer::Docker::Http::H2
58
+ include OpenSSL
38
59
 
39
60
  STATE_READ_HEADER = 1
40
61
  STATE_READ_CONTENT = 2
@@ -42,6 +63,7 @@ module Baykit
42
63
 
43
64
  FIXED_REQ_ID = 1
44
65
 
66
+ attr :protocol_handler
45
67
  attr :header_read
46
68
  attr :state
47
69
  attr :cur_req_id
@@ -49,17 +71,19 @@ module Baykit
49
71
  attr :cur_tour_id
50
72
  attr :http_protocol
51
73
 
52
- def initialize(pkt_store)
53
- super(pkt_store, true)
54
- reset()
74
+ def initialize
75
+ super
76
+ reset
77
+ end
78
+
79
+ def init(proto_handler)
80
+ @protocol_handler = proto_handler
55
81
  end
56
82
 
57
83
  ######################################################
58
84
  # implements Reusable
59
85
  ######################################################
60
86
  def reset()
61
- super
62
- @cur_req_id = 1
63
87
  reset_state()
64
88
 
65
89
  @header_read = false
@@ -96,7 +120,7 @@ module Baykit
96
120
 
97
121
  tur.res.headers.set(Headers::CONNECTION, res_con)
98
122
 
99
- if BayServer.harbor.trace_header?
123
+ if BayServer.harbor.trace_header
100
124
  BayLog.info("%s resStatus:%d", tur, tur.res.headers.status)
101
125
  tur.res.headers.names.each do |name|
102
126
  tur.res.headers.values(name).each do |value|
@@ -106,34 +130,34 @@ module Baykit
106
130
  end
107
131
 
108
132
  cmd = CmdHeader.new_res_header(tur.res.headers, tur.req.protocol)
109
- @command_packer.post(@ship, cmd)
133
+ @protocol_handler.post(cmd)
110
134
  end
111
135
 
112
136
  def send_res_content(tur, bytes, ofs, len, &callback)
113
137
  BayLog.debug("%s H1 send_res_content len=%d", self, len)
114
138
  cmd = CmdContent.new(bytes, ofs, len)
115
- @command_packer.post(@ship, cmd, &callback)
139
+ @protocol_handler.post(cmd, &callback)
116
140
  end
117
141
 
118
142
  def send_end_tour(tur, keep_alive, &callback)
119
- BayLog.trace("%s sendEndTour: tur=%s keep=%s", @ship, tur, keep_alive)
143
+ BayLog.trace("%s sendEndTour: tur=%s keep=%s", ship, tur, keep_alive)
120
144
 
121
145
  # Send dummy end request command
122
146
  cmd = CmdEndContent.new()
123
147
 
124
- sid = @ship.ship_id
148
+ sid = ship.ship_id
125
149
  ensure_func = lambda do
126
- if keep_alive && !@ship.postman.zombie?
127
- @ship.keeping = true
128
- @ship.resume(sid)
150
+ if keep_alive
151
+ ship.keeping = true
152
+ ship.resume_read(sid)
129
153
  else
130
- @command_packer.end(@ship)
154
+ ship.post_close
131
155
  end
132
156
  end
133
157
 
134
158
  begin
135
- @command_packer.post(@ship, cmd) do
136
- BayLog.debug("%s call back of end content command: tur=%s", @ship, tur)
159
+ @protocol_handler.post(cmd) do
160
+ BayLog.debug("%s call back of end content command: tur=%s", ship, tur)
137
161
  ensure_func.call()
138
162
  callback.call()
139
163
  end
@@ -143,9 +167,9 @@ module Baykit
143
167
  end
144
168
  end
145
169
 
146
- def send_req_protocol_error(err)
170
+ def on_protocol_error(err)
147
171
  if @cur_tour == nil
148
- tur = @ship.get_error_tour()
172
+ tur = ship.get_error_tour()
149
173
  else
150
174
  tur = @cur_tour
151
175
  end
@@ -158,7 +182,8 @@ module Baykit
158
182
  # implements H1CommandHandler
159
183
  ######################################################
160
184
  def handle_header(cmd)
161
- BayLog.debug("%s handleHeader: method=%s uri=%s proto=", @ship, cmd.method, cmd.uri, cmd.version);
185
+ BayLog.debug("%s handleHeader: method=%s uri=%s proto=", ship, cmd.method, cmd.uri, cmd.version);
186
+ sip = ship
162
187
 
163
188
  if @state == STATE_FINISHED
164
189
  change_state(STATE_READ_HEADER)
@@ -174,10 +199,10 @@ module Baykit
174
199
  # Check HTTP2
175
200
  protocol = cmd.version.upcase
176
201
  if protocol == "HTTP/2.0"
177
- if @ship.port_docker.support_h2
178
- @ship.port_docker.return_protocol_handler(@ship.agent, self)
179
- new_hnd = ProtocolHandlerStore.get_store(HtpDocker::H2_PROTO_NAME, true, @ship.agent.agent_id).rent()
180
- @ship.set_protocol_handler(new_hnd)
202
+ if ship.port_docker.support_h2
203
+ ship.port_docker.return_protocol_handler(ship.agent_id, @protocol_handler)
204
+ new_hnd = ProtocolHandlerStore.get_store(HtpDocker::H2_PROTO_NAME, true, sip.agent_id).rent()
205
+ sip.set_protocol_handler(new_hnd)
181
206
  raise UpgradeException.new()
182
207
  else
183
208
  raise ProtocolException.new(
@@ -185,11 +210,11 @@ module Baykit
185
210
  end
186
211
  end
187
212
 
188
- tur = @ship.get_tour(@cur_req_id)
213
+ tur = sip.get_tour(@cur_req_id)
189
214
 
190
215
  if tur == nil
191
216
  BayLog.error(BayMessage.get(:INT_NO_MORE_TOURS))
192
- tur = @ship.get_tour(self.cur_req_id, true)
217
+ tur = sip.get_tour(self.cur_req_id, true)
193
218
  tur.res.send_error(Tour::TOUR_ID_NOCHECK, HttpStatus::SERVICE_UNAVAILABLE, "No available tours")
194
219
  return NextSocketAction::CONTINUE
195
220
  end
@@ -198,7 +223,7 @@ module Baykit
198
223
  @cur_tour_id = tur.id()
199
224
  @cur_req_id += 1
200
225
 
201
- @ship.keeping = false
226
+ ship.keeping = false
202
227
 
203
228
  @http_protocol = protocol
204
229
 
@@ -219,21 +244,16 @@ module Baykit
219
244
 
220
245
  req_cont_len = tur.req.headers.content_length
221
246
  BayLog.debug("%s read header method=%s protocol=%s uri=%s contlen=%d",
222
- @ship, tur.req.method, tur.req.protocol, tur.req.uri, tur.req.headers.content_length)
247
+ ship, tur.req.method, tur.req.protocol, tur.req.uri, tur.req.headers.content_length)
223
248
 
224
- if BayServer.harbor.trace_header?
249
+ if BayServer.harbor.trace_header
225
250
  cmd.headers.each do |item|
226
251
  BayLog.info("%s h1: reqHeader: %s=%s", tur, item[0], item[1])
227
252
  end
228
253
  end
229
254
 
230
255
  if req_cont_len > 0
231
- sid = @ship.ship_id
232
- tur.req.set_consume_listener(req_cont_len) do |len, resume|
233
- if resume
234
- @ship.resume(sid)
235
- end
236
- end
256
+ tur.req.set_limit(req_cont_len)
237
257
  end
238
258
 
239
259
  begin
@@ -247,9 +267,10 @@ module Baykit
247
267
  return NextSocketAction::CONTINUE
248
268
  end
249
269
  rescue HttpException => e
250
- BayLog.debug("%s Http error occurred: %s", self, e)
270
+ BayLog.debug_e(e, "%s Http error occurred: %s", self, e)
251
271
  if req_cont_len <= 0
252
272
  # no post data
273
+ tur.req.abort
253
274
  tur.res.send_http_exception(Tour::TOUR_ID_NOCHECK, e)
254
275
 
255
276
  reset_state() # next: read empty stdin command
@@ -266,7 +287,7 @@ module Baykit
266
287
  end
267
288
 
268
289
  def handle_content(cmd)
269
- BayLog.debug("%s handleContent: len=%s", @ship, cmd.len)
290
+ BayLog.debug("%s handleContent: len=%s", ship, cmd.len)
270
291
 
271
292
  if @state != STATE_READ_CONTENT
272
293
  s = @state
@@ -276,30 +297,38 @@ module Baykit
276
297
 
277
298
  tur = @cur_tour
278
299
  tur_id = @cur_tour_id
279
- success = tur.req.post_content(tur_id, cmd.buf, cmd.start, cmd.len)
280
-
281
- if tur.req.bytes_posted == tur.req.bytes_limit
282
- if tur.error != nil
283
- # Error has occurred on header completed
284
- tur.res.send_http_exception(tur_id, tur.error)
285
- reset_state()
286
- return NextSocketAction::WRITE
287
- else
288
- begin
300
+ begin
301
+ sid = ship.ship_id
302
+ success = tur.req.post_req_content(tur_id, cmd.buf, cmd.start, cmd.len) do |len, resume|
303
+ if resume
304
+ tur.ship.resume_read(sid)
305
+ end
306
+ end
307
+
308
+ if tur.req.bytes_posted == tur.req.bytes_limit
309
+ if tur.error != nil
310
+ # Error has occurred on header completed
311
+ #tur.res.send_http_exception(tur_id, tur.error)
312
+ #reset_state()
313
+ #return NextSocketAction::WRITE
314
+ BayLog.debug("%s Delay report error", tur)
315
+ raise tur.error
316
+ else
289
317
  end_req_content(tur_id, tur)
290
- return NextSocketAction::SUSPEND # end reading
291
- rescue HttpException => e
292
- tur.res.send_http_exception(tur_id, e)
293
- reset_state()
294
- return NextSocketAction::WRITE
318
+ return NextSocketAction::CONTINUE
295
319
  end
296
320
  end
297
- end
298
321
 
299
- if !success
300
- return NextSocketAction::SUSPEND
301
- else
302
- return NextSocketAction::CONTINUE
322
+ if !success
323
+ return NextSocketAction::SUSPEND # end reading
324
+ else
325
+ return NextSocketAction::CONTINUE
326
+ end
327
+
328
+ rescue HttpException => e
329
+ tur.res.send_http_exception(tur_id, e)
330
+ reset_state()
331
+ return NextSocketAction::WRITE
303
332
  end
304
333
  end
305
334
 
@@ -307,13 +336,15 @@ module Baykit
307
336
  raise Sink.new()
308
337
  end
309
338
 
310
- def finished()
339
+ def req_finished()
311
340
  return @state == STATE_FINISHED
312
341
  end
313
342
 
314
-
315
-
316
343
  private
344
+ def ship
345
+ return @protocol_handler.ship
346
+ end
347
+
317
348
  def change_state(new_state)
318
349
  @state = new_state
319
350
  end
@@ -325,16 +356,19 @@ module Baykit
325
356
  end
326
357
 
327
358
  def end_req_content(chk_tur_id, tur)
328
- tur.req.end_content(chk_tur_id)
359
+ tur.req.end_req_content(chk_tur_id)
329
360
  reset_state()
330
361
  end
331
362
 
332
363
  def start_tour(tur)
333
- secure = @ship.port_docker.secure
364
+ secure = ship.port_docker.secure
334
365
  HttpUtil.parse_host_port(tur, secure ? 443 : 80)
335
366
  HttpUtil.parse_authorization(tur)
336
367
 
337
- skt = @ship.socket
368
+ skt = ship.rudder.io
369
+ if skt.kind_of? SSL::SSLSocket
370
+ skt = skt.io
371
+ end
338
372
 
339
373
  client_adr = tur.req.headers.get(Headers::X_FORWARDED_FOR)
340
374
  if client_adr
@@ -10,7 +10,6 @@ module Baykit
10
10
  module Http
11
11
  module H1
12
12
  class H1ProtocolHandler < Baykit::BayServer::Protocol::ProtocolHandler
13
- include Baykit::BayServer::Docker::Http::H1::H1CommandHandler # implements
14
13
 
15
14
  include Baykit::BayServer::Agent
16
15
  include Baykit::BayServer::Protocol
@@ -20,17 +19,8 @@ module Baykit
20
19
 
21
20
  attr :keeping
22
21
 
23
- def initialize(pkt_store, svr_mode)
24
- @command_unpacker = H1CommandUnPacker.new(self, svr_mode)
25
- @packet_unpacker = H1PacketUnPacker.new(@command_unpacker, pkt_store)
26
- @packet_packer = PacketPacker.new()
27
- @command_packer = CommandPacker.new(@packet_packer, pkt_store)
28
- @server_mode = svr_mode
29
- @keeping = false
30
- end
31
-
32
- def inspect()
33
- return @ship.inspect()
22
+ def initialize(h1_handler, pkt_unpacker, pkt_packer, cmd_unpacker, cmd_packer, svr_mode)
23
+ super(pkt_unpacker, pkt_packer, cmd_unpacker, cmd_packer, h1_handler, svr_mode)
34
24
  end
35
25
 
36
26
  ######################################################
@@ -1,6 +1,6 @@
1
1
  require 'baykit/bayserver/tours/tour'
2
2
  require 'baykit/bayserver/protocol/protocol_exception'
3
- require 'baykit/bayserver/docker/warp/package'
3
+ require 'baykit/bayserver/common/warp_handler'
4
4
  require 'baykit/bayserver/docker/http/h1/command/package'
5
5
 
6
6
  module Baykit
@@ -8,14 +8,25 @@ module Baykit
8
8
  module Docker
9
9
  module Http
10
10
  module H1
11
- class H1WarpHandler < H1ProtocolHandler
12
- include Baykit::BayServer::Docker::Warp::WarpHandler # implements
11
+ class H1WarpHandler
12
+ include Baykit::BayServer::Common::WarpHandler # implements
13
+ include H1Handler # implements
14
+ include Baykit::BayServer::Protocol
13
15
 
14
16
  class WarpProtocolHandlerFactory
15
17
  include Baykit::BayServer::Protocol::ProtocolHandlerFactory # implements
18
+ include Baykit::BayServer::Protocol
16
19
 
17
20
  def create_protocol_handler(pkt_store)
18
- return H1WarpHandler.new(pkt_store)
21
+ ib_handler = H1WarpHandler.new
22
+ cmd_unpacker = H1CommandUnPacker.new(ib_handler, false)
23
+ pkt_unpacker = H1PacketUnPacker.new(cmd_unpacker, pkt_store)
24
+ pkt_packer = PacketPacker.new
25
+ cmd_packer = CommandPacker.new(pkt_packer, pkt_store)
26
+
27
+ proto_handler = H1ProtocolHandler.new(ib_handler, pkt_unpacker, pkt_packer, cmd_unpacker, cmd_packer, true)
28
+ ib_handler.init(proto_handler)
29
+ return proto_handler
19
30
  end
20
31
  end
21
32
 
@@ -23,7 +34,7 @@ module Baykit
23
34
  include Baykit::BayServer::Tours
24
35
  include Baykit::BayServer::Agent
25
36
  include Baykit::BayServer::Util
26
- include Baykit::BayServer::Docker::Warp
37
+ include Baykit::BayServer::Common
27
38
  include Baykit::BayServer::Docker::Http::H1::Command
28
39
 
29
40
  STATE_READ_HEADER = 1
@@ -32,35 +43,35 @@ module Baykit
32
43
 
33
44
  FIXED_WARP_ID = 1
34
45
 
46
+ attr :protocol_handler
35
47
  attr :state
36
48
 
37
- def initialize(pkt_store)
38
- super(pkt_store, false)
49
+ def initialize()
39
50
  reset()
40
51
  end
41
52
 
42
- ######################################################
43
- # Implements Reusable
44
- ######################################################
53
+ def init(proto_handler)
54
+ @protocol_handler = proto_handler
55
+ end
45
56
 
46
- def reset()
47
- super
48
- change_state(STATE_FINISHED)
57
+ def to_s
58
+ return ship.to_s
49
59
  end
50
60
 
51
61
 
52
62
  ######################################################
53
- # Implements WarpHandler
63
+ # Implements Reusable
54
64
  ######################################################
55
- def next_warp_id
56
- return H1WarpHandler::FIXED_WARP_ID
57
- end
58
65
 
59
- def new_warp_data(warp_id)
60
- return WarpData.new(@ship, warp_id)
66
+ def reset
67
+ reset_state
61
68
  end
62
69
 
63
- def post_warp_headers(tur)
70
+ ######################################################
71
+ # Implements TourHandler
72
+ ######################################################
73
+
74
+ def send_res_headers(tur)
64
75
  twn = tur.town
65
76
 
66
77
  twn_path = twn.name
@@ -68,7 +79,7 @@ module Baykit
68
79
  twn_path += "/"
69
80
  end
70
81
 
71
- new_uri = @ship.docker.warp_base + tur.req.uri[twn_path.length .. -1]
82
+ new_uri = ship.docker.warp_base + tur.req.uri[twn_path.length .. -1]
72
83
  cmd = CmdHeader.new_req_header(tur.req.method, new_uri, "HTTP/1.1")
73
84
 
74
85
  tur.req.headers.names.each do |name|
@@ -101,31 +112,39 @@ module Baykit
101
112
  cmd.set_header(Headers::X_FORWARDED_HOST, tur.req.headers.get(Headers::HOST))
102
113
  end
103
114
 
104
- cmd.set_header(Headers::HOST, "#{@ship.docker.host}:#{@ship.docker.port}")
115
+ cmd.set_header(Headers::HOST, "#{ship.docker.host}:#{ship.docker.port}")
105
116
  cmd.set_header(Headers::CONNECTION, "Keep-Alive")
106
117
 
107
- if BayServer.harbor.trace_header?
118
+ if BayServer.harbor.trace_header
108
119
  cmd.headers.each do |kv|
109
120
  BayLog.info("%s warp_http reqHdr: %s=%s", tur, kv[0], kv[1])
110
121
  end
111
122
  end
112
123
 
113
124
 
114
- @ship.post(cmd)
125
+ ship.post(cmd)
115
126
  end
116
127
 
117
- def post_warp_contents(tur, buf, start, len, &callback)
128
+ def send_res_content(tur, buf, start, len, &callback)
118
129
  cmd = CmdContent.new(buf, start, len)
119
- @ship.post(cmd, callback)
130
+ ship.post(cmd, &callback)
120
131
  end
121
132
 
122
- def post_warp_end(tur)
133
+ def send_end_tour(tur, keep_alive, &lis)
123
134
  cmd = CmdEndContent.new()
124
- callback = lambda do
125
- @ship.agent.non_blocking_handler.ask_to_read(@ship.socket)
126
- end
135
+ ship.post(cmd, &lis)
136
+ end
127
137
 
128
- @ship.post(cmd, callback)
138
+
139
+ ######################################################
140
+ # Implements WarpHandler
141
+ ######################################################
142
+ def next_warp_id
143
+ return H1WarpHandler::FIXED_WARP_ID
144
+ end
145
+
146
+ def new_warp_data(warp_id)
147
+ return WarpData.new(ship, warp_id)
129
148
  end
130
149
 
131
150
  def verify_protocol(proto)
@@ -137,26 +156,26 @@ module Baykit
137
156
  ######################################################
138
157
 
139
158
  def handle_header(cmd)
140
- tur = @ship.get_tour(FIXED_WARP_ID)
159
+ tur = ship.get_tour(FIXED_WARP_ID)
141
160
  wdat = WarpData.get(tur)
142
161
  BayLog.debug("%s handleHeader status=%d", wdat, cmd.status);
143
- @ship.keeping = false
162
+ ship.keeping = false
144
163
 
145
164
  if @state == STATE_FINISHED
146
165
  change_state(STATE_READ_HEADER)
147
166
  end
148
167
 
149
168
  if @state != STATE_READ_HEADER
150
- raise ProtocolException("Header command not expected: state=%d", @state)
169
+ raise ProtocolException.new("Header command not expected: state=%d", @state)
151
170
  end
152
171
 
153
- if BayServer.harbor.trace_header?
172
+ if BayServer.harbor.trace_header
154
173
  BayLog.info("%s warp_http: resStatus: %d", wdat, cmd.status)
155
174
  end
156
175
 
157
176
  cmd.headers.each do |nv|
158
177
  tur.res.headers.add(nv[0], nv[1])
159
- if BayServer.harbor.trace_header?
178
+ if BayServer.harbor.trace_header
160
179
  BayLog.info("%s warp_http: resHeader: %s=%s", wdat, nv[0], nv[1]);
161
180
  end
162
181
  end
@@ -170,10 +189,10 @@ module Baykit
170
189
  end_res_content(tur)
171
190
  else
172
191
  change_state(STATE_READ_CONTENT)
173
- sid = @ship.id()
192
+ sid = ship.id()
174
193
  tur.res.set_consume_listener do |len, resume|
175
194
  if resume
176
- @ship.resume(sid)
195
+ ship.resume_read(sid)
177
196
  end
178
197
  end
179
198
  end
@@ -181,7 +200,7 @@ module Baykit
181
200
  end
182
201
 
183
202
  def handle_content(cmd)
184
- tur = @ship.get_tour(FIXED_WARP_ID)
203
+ tur = ship.get_tour(FIXED_WARP_ID)
185
204
  wdat = WarpData.get(tur)
186
205
  BayLog.debug("%s handleContent len=%d posted%d contLen=%d", wdat, cmd.len, tur.res.bytes_posted, tur.res.bytes_limit);
187
206
 
@@ -189,7 +208,7 @@ module Baykit
189
208
  raise ProtocolException.new("Content command not expected")
190
209
  end
191
210
 
192
- available = tur.res.send_content(Tour::TOUR_ID_NOCHECK, cmd.buf, cmd.start, cmd.len)
211
+ available = tur.res.send_res_content(Tour::TOUR_ID_NOCHECK, cmd.buf, cmd.start, cmd.len)
193
212
  if tur.res.bytes_posted == tur.res.bytes_limit
194
213
  end_res_content(tur)
195
214
  return NextSocketAction::CONTINUE
@@ -204,26 +223,30 @@ module Baykit
204
223
  raise Sink.new()
205
224
  end
206
225
 
207
- def finished()
226
+ def req_finished
208
227
  return @state == STATE_FINISHED
209
228
  end
210
229
 
211
- def to_s
212
- return @ship.to_s
213
- end
214
-
215
230
  private
216
231
 
232
+ def reset_state
233
+ change_state(STATE_FINISHED)
234
+ end
235
+
217
236
  def end_res_content(tur)
218
- @ship.end_warp_tour(tur)
219
- tur.res.end_content(Tour::TOUR_ID_NOCHECK)
220
- reset()
221
- @ship.keeping = true
237
+ ship.end_warp_tour(tur)
238
+ tur.res.end_res_content(Tour::TOUR_ID_NOCHECK)
239
+ reset_state
240
+ ship.keeping = true
222
241
  end
223
242
 
224
243
  def change_state(new_state)
225
244
  @state = new_state
226
245
  end
246
+
247
+ def ship
248
+ return @protocol_handler.ship
249
+ end
227
250
  end
228
251
  end
229
252
  end
@@ -22,7 +22,6 @@ module Baykit
22
22
 
23
23
  def initialize(stream_id, flags=nil)
24
24
  super(H2Type::WINDOW_UPDATE, stream_id, flags)
25
- @items = []
26
25
  end
27
26
 
28
27
  def unpack(pkt)
@@ -6,19 +6,41 @@ module Baykit
6
6
  module H2CommandHandler
7
7
  include Baykit::BayServer::Protocol::CommandHandler # implements
8
8
 
9
- #
10
- # abstract methods
11
- #
12
- # handle_preface(cmd)
13
- # handle_data(cmd)
14
- # handle_headers(cmd)
15
- # handle_priority(cmd)
16
- # handle_settings(cmd)
17
- # handle_window_update(cmd)
18
- # handle_go_away(cmd)
19
- # handle_ping(cmd)
20
- # handle_rst_stream(cmd)
21
- #
9
+ def handle_preface(cmd)
10
+ raise NotImplementedError.new
11
+ end
12
+
13
+ def handle_data(cmd)
14
+ raise NotImplementedError.new
15
+ end
16
+
17
+ def handle_headers(cmd)
18
+ raise NotImplementedError.new
19
+ end
20
+
21
+ def handle_priority(cmd)
22
+ raise NotImplementedError.new
23
+ end
24
+
25
+ def handle_settings(cmd)
26
+ raise NotImplementedError.new
27
+ end
28
+
29
+ def handle_window_update(cmd)
30
+ raise NotImplementedError.new
31
+ end
32
+
33
+ def handle_go_away(cmd)
34
+ raise NotImplementedError.new
35
+ end
36
+
37
+ def handle_ping(cmd)
38
+ raise NotImplementedError.new
39
+ end
40
+
41
+ def handle_rst_stream(cmd)
42
+ raise NotImplementedError.new
43
+ end
22
44
  end
23
45
  end
24
46
  end
@@ -0,0 +1,15 @@
1
+ module Baykit
2
+ module BayServer
3
+ module Docker
4
+ module Http
5
+ module H2
6
+ module H2Handler # interface
7
+ def on_protocol_error(e)
8
+ raise NotImplementedError.new
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,11 @@
1
- require 'baykit/bayserver/docker/base/inbound_handler'
1
+ require 'baykit/bayserver/common/inbound_handler'
2
+
3
+ require 'baykit/bayserver/protocol/packet_packer'
4
+ require 'baykit/bayserver/protocol/command_packer'
2
5
 
3
6
  require 'baykit/bayserver/docker/http/h2/package'
4
7
  require 'baykit/bayserver/docker/http/h2/h2_protocol_handler'
8
+ require 'baykit/bayserver/docker/http/h2/h2_handler'
5
9
  require 'baykit/bayserver/docker/http/h2/command/package'
6
10
  require 'baykit/bayserver/protocol/package'
7
11
  require 'baykit/bayserver/tours/req_content_handler'
@@ -15,17 +19,30 @@ module Baykit
15
19
  module Docker
16
20
  module Http
17
21
  module H2
18
- class H2InboundHandler < Baykit::BayServer::Docker::Http::H2::H2ProtocolHandler
22
+ class H2InboundHandler
19
23
 
20
24
  class InboundProtocolHandlerFactory
21
25
  include Baykit::BayServer::Protocol::ProtocolHandlerFactory # implements
22
26
 
27
+ include Baykit::BayServer::Protocol
28
+
23
29
  def create_protocol_handler(pkt_store)
24
- return H2InboundHandler.new(pkt_store)
30
+
31
+ ib_handler = H2InboundHandler.new
32
+ cmd_unpacker = H2CommandUnPacker.new(ib_handler)
33
+ pkt_unpacker = H2PacketUnPacker.new(cmd_unpacker, pkt_store, true)
34
+ pkt_packer = PacketPacker.new()
35
+ cmd_packer = CommandPacker.new(pkt_packer, pkt_store)
36
+
37
+ proto_handler = H2ProtocolHandler.new(ib_handler, pkt_unpacker, pkt_packer, cmd_unpacker, cmd_packer, true)
38
+ ib_handler.init(proto_handler)
39
+ return proto_handler
25
40
  end
26
41
  end
27
42
 
28
- include Baykit::BayServer::Docker::Base::InboundHandler # implements
43
+ include Baykit::BayServer::Common::InboundHandler # implements
44
+ include H2Handler # implements
45
+
29
46
  include Baykit::BayServer::Agent
30
47
  include Baykit::BayServer::Protocol
31
48
  include Baykit::BayServer::WaterCraft
@@ -33,6 +50,7 @@ module Baykit
33
50
  include Baykit::BayServer::Util
34
51
  include Baykit::BayServer::Docker::Http::H2::Command
35
52
 
53
+ attr :protocol_handler
36
54
  attr :req_cont_len
37
55
  attr :req_cont_read
38
56
  attr :header_read
@@ -40,12 +58,15 @@ module Baykit
40
58
  attr :settings
41
59
  attr :analyzer
42
60
  attr :http_protocol
61
+ attr :req_header_tbl
62
+ attr :res_header_tbl
43
63
 
44
- def initialize(pkt_store)
45
- super(pkt_store, true)
64
+ def initialize
46
65
  @window_size = BayServer.harbor.tour_buffer_size
47
66
  @settings = H2Settings.new
48
67
  @analyzer = HeaderBlockAnalyzer.new
68
+ @req_header_tbl = HeaderTable.create_dynamic_table()
69
+ @res_header_tbl = HeaderTable.create_dynamic_table()
49
70
  end
50
71
 
51
72
  ######################################################
@@ -53,12 +74,15 @@ module Baykit
53
74
  ######################################################
54
75
 
55
76
  def reset()
56
- super
57
77
  @header_read = false
58
78
  @req_cont_len = 0
59
79
  @req_cont_read = 0
60
80
  end
61
81
 
82
+ def init(proto_handler)
83
+ @protocol_handler = proto_handler
84
+ end
85
+
62
86
  ######################################################
63
87
  # implements InboundHandler
64
88
  ######################################################
@@ -70,7 +94,7 @@ module Baykit
70
94
  cmd.header_blocks << blk
71
95
 
72
96
  # headers
73
- if BayServer.harbor.trace_header?
97
+ if BayServer.harbor.trace_header
74
98
  BayLog.info("%s res status: %d", tur, tur.res.headers.status)
75
99
  end
76
100
  tur.res.headers.names.each do |name|
@@ -78,7 +102,7 @@ module Baykit
78
102
  BayLog.trace("%s Connection header is discarded", tur)
79
103
  else
80
104
  tur.res.headers.values(name).each do |value|
81
- if BayServer.harbor.trace_header?
105
+ if BayServer.harbor.trace_header
82
106
  BayLog.info("%s H2 res header: %s=%s", tur, name, value)
83
107
  end
84
108
  blk = bld.build_header_block(name, value, @res_header_tbl)
@@ -90,21 +114,23 @@ module Baykit
90
114
  cmd.flags.set_end_headers(true)
91
115
  cmd.excluded = true
92
116
  cmd.flags.set_padded(false)
93
- @command_packer.post(@ship, cmd)
117
+ @protocol_handler.post(cmd)
94
118
  end
95
119
 
96
- def send_res_content(tur, bytes, ofs, len, &lis)
120
+ def send_res_content(tur, bytes, ofs, len, &callback)
121
+ BayLog.debug("%s send_res_content len=%d", self, len)
97
122
  cmd = CmdData.new(tur.req.key, nil, bytes, ofs, len);
98
- @command_packer.post(@ship, cmd, &lis)
123
+ @protocol_handler.post(cmd, &callback)
99
124
  end
100
125
 
101
126
  def send_end_tour(tur, keep_alive, &callback)
127
+ BayLog.debug("%s send_end_tour. keep=%s", self, keep_alive)
102
128
  cmd = CmdData.new(tur.req.key, nil, [], 0, 0)
103
129
  cmd.flags.set_end_stream(true)
104
- @command_packer.post(@ship, cmd, &callback)
130
+ @protocol_handler.post(cmd, &callback)
105
131
  end
106
132
 
107
- def send_req_protocol_error(err)
133
+ def on_protocol_error(err)
108
134
  BayLog.error_e err
109
135
  cmd = CmdGoAway.new(CTL_STREAM_ID)
110
136
  cmd.stream_id = CTL_STREAM_ID
@@ -112,8 +138,8 @@ module Baykit
112
138
  cmd.error_code = H2ErrorCode::PROTOCOL_ERROR
113
139
  cmd.debug_data = "Thank you!"
114
140
  begin
115
- @command_packer.post(@ship, cmd)
116
- @command_packer.end(@ship)
141
+ @protocol_handler.post(cmd)
142
+ @protocol_handler.end(ship)
117
143
  rescue IOError => e
118
144
  BayLog.error_e(e)
119
145
  end
@@ -126,7 +152,7 @@ module Baykit
126
152
  ######################################################
127
153
 
128
154
  def handle_preface(cmd)
129
- BayLog.debug("%s h2: handle_preface: proto=%s", @ship, cmd.protocol)
155
+ BayLog.debug("%s h2: handle_preface: proto=%s", ship, cmd.protocol)
130
156
 
131
157
  @http_protocol = cmd.protocol
132
158
 
@@ -134,7 +160,7 @@ module Baykit
134
160
  set.stream_id = 0
135
161
  set.items.append(CmdSettings::Item.new(CmdSettings::MAX_CONCURRENT_STREAMS, TourStore::MAX_TOURS))
136
162
  set.items.append(CmdSettings::Item.new(CmdSettings::INITIAL_WINDOW_SIZE, @window_size))
137
- @command_packer.post(@ship, set)
163
+ @protocol_handler.post(set)
138
164
 
139
165
  set = CmdSettings.new(H2ProtocolHandler::CTL_STREAM_ID)
140
166
  set.stream_id = 0
@@ -145,12 +171,12 @@ module Baykit
145
171
 
146
172
 
147
173
  def handle_headers(cmd)
148
- BayLog.debug("%s handle_headers: stm=%d dep=%d weight=%d", @ship, cmd.stream_id, cmd.stream_dependency, cmd.weight)
174
+ BayLog.debug("%s handle_headers: stm=%d dep=%d weight=%d", ship, cmd.stream_id, cmd.stream_dependency, cmd.weight)
149
175
 
150
176
  tur = get_tour(cmd.stream_id)
151
177
  if tur == nil
152
178
  BayLog.error(BayMessage.get(:INT_NO_MORE_TOURS))
153
- tur = @ship.get_tour(cmd.stream_id, true)
179
+ tur = ship.get_tour(cmd.stream_id, true)
154
180
  tur.res.send_error(Tour::TOUR_ID_NOCHECK, HttpStatus::SERVICE_UNAVAILABLE, "No available tours")
155
181
  return NextSocketAction::CONTINUE
156
182
  end
@@ -162,7 +188,7 @@ module Baykit
162
188
  next
163
189
  end
164
190
  @analyzer.analyze_header_block(blk, @req_header_tbl)
165
- if BayServer.harbor.trace_header?
191
+ if BayServer.harbor.trace_header
166
192
  BayLog.info("%s req header: %s=%s :%s", tur, @analyzer.name, @analyzer.value, blk);
167
193
  end
168
194
 
@@ -188,33 +214,12 @@ module Baykit
188
214
  if cmd.flags.end_headers?
189
215
  tur.req.protocol = "HTTP/2.0"
190
216
  BayLog.debug("%s H2 read header method=%s protocol=%s uri=%s contlen=%d",
191
- @ship, tur.req.method, tur.req.protocol, tur.req.uri, tur.req.headers.content_length)
217
+ ship, tur.req.method, tur.req.protocol, tur.req.uri, tur.req.headers.content_length)
192
218
 
193
219
  req_cont_len = tur.req.headers.content_length()
194
220
 
195
221
  if req_cont_len > 0
196
- sid = @ship.ship_id
197
- tur.req.set_consume_listener(req_cont_len) do |len, resume|
198
- @ship.check_ship_id(sid)
199
- if len > 0
200
- upd = CmdWindowUpdate.new(cmd.stream_id)
201
- upd.window_size_increment = len
202
- upd2 = CmdWindowUpdate.new( 0)
203
- upd2.window_size_increment = len
204
- cmd_packer = @command_packer
205
- begin
206
- cmd_packer.post(@ship, upd)
207
- cmd_packer.post(@ship, upd2)
208
- rescue IOError => e
209
- BayLog.error_e(e)
210
- end
211
- end
212
-
213
- if resume
214
- @ship.resume(Ship::SHIP_ID_NOCHECK)
215
- end
216
- end
217
-
222
+ tur.req.set_limit(req_cont_len)
218
223
  end
219
224
 
220
225
  begin
@@ -227,6 +232,7 @@ module Baykit
227
232
  BayLog.debug("%s Http error occurred: %s", self, e);
228
233
  if req_cont_len <= 0
229
234
  # no post data
235
+ tur.req.abort
230
236
  tur.res.send_http_exception(Tour::TOUR_ID_NOCHECK, e)
231
237
 
232
238
  return NextSocketAction::CONTINUE
@@ -244,7 +250,7 @@ module Baykit
244
250
  end
245
251
 
246
252
  def handle_data(cmd)
247
- BayLog.debug("%s handle_data: stm=%d len=%d", @ship, cmd.stream_id, cmd.length)
253
+ BayLog.debug("%s handle_data: stm=%d len=%d", ship, cmd.stream_id, cmd.length)
248
254
 
249
255
  tur = get_tour(cmd.stream_id)
250
256
  if tur == nil
@@ -254,29 +260,51 @@ module Baykit
254
260
  raise ProtocolException.new("Post content not allowed")
255
261
  end
256
262
 
257
- success = false
258
- if cmd.length > 0
259
- success = tur.req.post_content(Tour::TOUR_ID_NOCHECK, cmd.data, cmd.start, cmd.length)
260
- if tur.req.bytes_posted >= tur.req.headers.content_length
261
- if tur.error != nil
262
- # Error has occurred on header completed
263
+ begin
264
+ success = false
265
+ if cmd.length > 0
266
+ tid = tur.tour_id
263
267
 
264
- tur.res.send_http_exception(Tour::TOUR_ID_NOCHECK, tur.error)
265
- return NextSocketAction::CONTINUE
266
- else
267
- begin
268
+ success = tur.req.post_req_content(Tour::TOUR_ID_NOCHECK, cmd.data, cmd.start, cmd.length) do |len, resume|
269
+ tur.check_tour_id(tid)
270
+ if len > 0
271
+ upd = CmdWindowUpdate.new(cmd.stream_id)
272
+ upd.window_size_increment = len
273
+ upd2 = CmdWindowUpdate.new( 0)
274
+ upd2.window_size_increment = len
275
+ begin
276
+ @protocol_handler.post(upd)
277
+ @protocol_handler.post(upd2)
278
+ rescue IOError => e
279
+ BayLog.error_e(e)
280
+ end
281
+ end
282
+
283
+ if resume
284
+ tur.ship.resume_read(Ship::SHIP_ID_NOCHECK)
285
+ end
286
+ end
287
+
288
+ if tur.req.bytes_posted >= tur.req.headers.content_length
289
+ if tur.error != nil
290
+ # Error has occurred on header completed
291
+ BayLog.debug("%s Delay report error", tur)
292
+ raise tur.error
293
+ else
268
294
  end_req_content(tur.id(), tur)
269
- rescue HttpException => e
270
- tur.res.send_http_exception(Tour::TOUR_ID_NOCHECK, e)
271
- return NextSocketAction::CONTINUE
272
295
  end
273
296
  end
274
297
  end
275
- end
276
298
 
277
- if !success
278
- return NextSocketAction::SUSPEND
279
- else
299
+ if !success
300
+ return NextSocketAction::SUSPEND
301
+ else
302
+ return NextSocketAction::CONTINUE
303
+ end
304
+
305
+ rescue HttpException => e
306
+ tur.req.abort
307
+ tur.res.send_http_exception(Tour::TOUR_ID_NOCHECK, e)
280
308
  return NextSocketAction::CONTINUE
281
309
  end
282
310
 
@@ -288,20 +316,20 @@ module Baykit
288
316
  end
289
317
 
290
318
  BayLog.debug("%s handlePriority: stmid=%d dep=%d, wgt=%d",
291
- @ship, cmd.stream_id, cmd.stream_dependency, cmd.weight);
319
+ ship, cmd.stream_id, cmd.stream_dependency, cmd.weight);
292
320
 
293
321
  return NextSocketAction::CONTINUE
294
322
  end
295
323
 
296
324
  def handle_settings(cmd)
297
- BayLog.debug("%s handleSettings: stmid=%d", @ship, cmd.stream_id);
325
+ BayLog.debug("%s handleSettings: stmid=%d", ship, cmd.stream_id);
298
326
 
299
327
  if cmd.flags.ack?
300
328
  return NextSocketAction::CONTINUE
301
329
  end
302
330
 
303
331
  cmd.items.each do |item|
304
- BayLog.debug("%s handle: Setting id=%d, value=%d", @ship, item.id, item.value);
332
+ BayLog.debug("%s handle: Setting id=%d, value=%d", ship, item.id, item.value);
305
333
  case item.id
306
334
  when CmdSettings::HEADER_TABLE_SIZE
307
335
  @settings.header_table_size = item.value
@@ -328,12 +356,12 @@ module Baykit
328
356
  end
329
357
 
330
358
  res = CmdSettings.new(0, H2Flags.new(H2Flags::FLAGS_ACK))
331
- @command_packer.post(@ship, res)
359
+ @protocol_handler.post(res)
332
360
  return NextSocketAction::CONTINUE
333
361
  end
334
362
 
335
363
  def handle_window_update(cmd)
336
- BayLog.debug("%s handleWindowUpdate: stmid=%d siz=%d", @ship, cmd.stream_id, cmd.window_size_increment);
364
+ BayLog.debug("%s handleWindowUpdate: stmid=%d siz=%d", ship, cmd.stream_id, cmd.window_size_increment);
337
365
 
338
366
  if cmd.window_size_increment == 0
339
367
  raise ProtocolException.new("Invalid increment value")
@@ -345,40 +373,54 @@ module Baykit
345
373
 
346
374
  def handle_go_away(cmd)
347
375
  BayLog.debug("%s received GoAway: lastStm=%d code=%d desc=%s debug=%s",
348
- @ship, cmd.last_stream_id, cmd.error_code, H2ErrorCode.msg.get(cmd.error_code.to_s.to_sym), cmd.debug_data);
376
+ ship, cmd.last_stream_id, cmd.error_code, H2ErrorCode.msg.get(cmd.error_code.to_s.to_sym), cmd.debug_data);
349
377
  return NextSocketAction::CLOSE
350
378
  end
351
379
 
352
380
  def handle_ping(cmd)
353
- BayLog.debug("%s handle_ping: stm=%d", @ship, cmd.stream_id)
381
+ BayLog.debug("%s handle_ping: stm=%d", ship, cmd.stream_id)
354
382
 
355
383
  res = CmdPing.new(cmd.stream_id, H2Flags.new(H2Flags::FLAGS_ACK), cmd.opaque_data)
356
- @command_packer.post(@ship, res)
384
+ @protocol_handler.post(res)
357
385
  return NextSocketAction::CONTINUE
358
386
  end
359
387
 
360
388
  def handle_rst_stream(cmd)
361
- BayLog.debug("%s received RstStream: stmid=%d code=%d desc=%s",
362
- @ship, cmd.stream_id, cmd.error_code, H2ErrorCode.msg.get(cmd.error_code.to_s.to_sym))
363
- return NextSocketAction::CONTINUE
389
+ BayLog.warn("%s received RstStream: stmid=%d code=%d desc=%s",
390
+ ship, cmd.stream_id, cmd.error_code, H2ErrorCode.msg.get(cmd.error_code.to_s.to_sym))
391
+ tur = get_tour(cmd.stream_id)
392
+ if tur == nil
393
+ BayLog.warn("%s stream not found id=%d", ship, cmd.stream_id)
394
+ else
395
+ tur.req.abort
396
+ return NextSocketAction::CONTINUE
397
+ end
364
398
  end
365
399
 
366
400
  private
401
+
402
+ def ship
403
+ return @protocol_handler.ship
404
+ end
405
+
367
406
  def get_tour(key)
368
- @ship.get_tour(key)
407
+ ship.get_tour(key)
369
408
  end
370
409
 
371
410
  def end_req_content(check_id, tur)
372
- tur.req.end_content check_id
411
+ tur.req.end_req_content check_id
373
412
  end
374
413
 
375
414
  def start_tour(tur)
376
- HttpUtil.parse_host_port(tur, @ship.port_docker.secure ? 443 : 80)
415
+ HttpUtil.parse_host_port(tur, ship.port_docker.secure ? 443 : 80)
377
416
  HttpUtil.parse_authorization(tur)
378
417
 
379
418
  tur.req.protocol = @http_protocol
380
419
 
381
- skt = @ship.socket
420
+ skt = ship.rudder.io
421
+ if skt.kind_of? OpenSSL::SSL::SSLSocket
422
+ skt = skt.io
423
+ end
382
424
 
383
425
  client_adr = tur.req.headers.get(Headers::X_FORWARDED_FOR)
384
426
  if client_adr
@@ -399,12 +441,12 @@ module Baykit
399
441
  server_port, tur.req.server_address = Socket.unpack_sockaddr_in(server_addr)
400
442
  rescue => e
401
443
  BayLog.error_e(e)
402
- BayLog.debug("%s Caught error (Continue)", @ship)
444
+ BayLog.debug("%s Caught error (Continue)", ship)
403
445
  end
404
446
 
405
447
  tur.req.server_port = tur.req.req_port
406
448
  tur.req.server_name = tur.req.req_host
407
- tur.is_secure = @ship.port_docker.secure
449
+ tur.is_secure = ship.port_docker.secure
408
450
 
409
451
  tur.go
410
452
  end
@@ -20,17 +20,9 @@ module Baykit
20
20
 
21
21
  CTL_STREAM_ID = 0
22
22
 
23
- attr :req_header_tbl
24
- attr :res_header_tbl
25
-
26
- def initialize(pkt_store, svr_mode)
27
- @command_unpacker = H2CommandUnPacker.new(self)
28
- @packet_unpacker = H2PacketUnPacker.new(@command_unpacker, pkt_store, svr_mode)
29
- @packet_packer = PacketPacker.new()
30
- @command_packer = CommandPacker.new(@packet_packer, pkt_store)
31
- @server_mode = svr_mode
32
- @req_header_tbl = HeaderTable.create_dynamic_table()
33
- @res_header_tbl = HeaderTable.create_dynamic_table()
23
+
24
+ def initialize(h2_handler, pkt_unpacker, pkt_packer, cmd_unpacker, cmd_packer, svr_mode)
25
+ super(pkt_unpacker, pkt_packer, cmd_unpacker, cmd_packer, h2_handler, svr_mode)
34
26
  end
35
27
 
36
28
  ######################################################
@@ -1,4 +1,4 @@
1
- require 'baykit/bayserver/docker/warp/package'
1
+ require 'baykit/bayserver/common/warp_handler'
2
2
  require 'baykit/bayserver/protocol/protocol_exception'
3
3
 
4
4
  module Baykit
@@ -7,7 +7,7 @@ module Baykit
7
7
  module Http
8
8
  module H2
9
9
  class H2WarpHandler < H2ProtocolHandler
10
- include Baykit::BayServer::Docker::Warp::WarpHandler # implements
10
+ include Baykit::BayServer::Common::WarpHandler # implements
11
11
 
12
12
  class WarpProtocolHandlerFactory
13
13
  include Baykit::BayServer::Protocol::ProtocolHandlerFactory # implements
@@ -1,6 +1,5 @@
1
1
  require 'baykit/bayserver/agent/transporter/package'
2
2
  require 'baykit/bayserver/docker/base/port_base'
3
- require 'baykit/bayserver/docker/warp/package'
4
3
  require 'baykit/bayserver/docker/http/h1/package'
5
4
 
6
5
 
@@ -2,8 +2,8 @@ require 'openssl'
2
2
 
3
3
  require 'baykit/bayserver/agent/transporter/package'
4
4
  require 'baykit/bayserver/docker/base/port_base'
5
+ require 'baykit/bayserver/docker/base/warp_base'
5
6
  require 'baykit/bayserver/protocol/packet_store'
6
- require 'baykit/bayserver/docker/warp/package'
7
7
  require 'baykit/bayserver/docker/http/h1/package'
8
8
  require 'baykit/bayserver/docker/http/h2/package'
9
9
 
@@ -12,7 +12,7 @@ module Baykit
12
12
  module BayServer
13
13
  module Docker
14
14
  module Http
15
- class HtpWarpDocker < Baykit::BayServer::Docker::Warp::WarpDocker
15
+ class HtpWarpDocker < Baykit::BayServer::Docker::Base::WarpBase
16
16
  include Baykit::BayServer::Docker::Http::HtpDocker # implements
17
17
 
18
18
  include OpenSSL
@@ -89,12 +89,25 @@ module Baykit
89
89
  return H1_PROTO_NAME
90
90
  end
91
91
 
92
- def new_transporter(agt, skt)
92
+ def new_transporter(agt, rd, sip)
93
93
  if @secure
94
- return SecureTransporter.new(@ssl_ctx, false, IOUtil.get_sock_recv_buf_size(skt), @trace_ssl)
94
+ tp = SecureTransporter.new(
95
+ agt.net_multiplexer,
96
+ sip,
97
+ false,
98
+ false, IOUtil.get_sock_recv_buf_size(rd.io),
99
+ @trace_ssl,
100
+ @ssl_ctx)
95
101
  else
96
- return PlainTransporter.new(false, IOUtil.get_sock_recv_buf_size(skt))
102
+ tp = PlainTransporter.new(
103
+ agt.net_multiplexer,
104
+ sip,
105
+ false,
106
+ IOUtil.get_sock_recv_buf_size(rd.io),
107
+ false)
97
108
  end
109
+ tp.init
110
+ return tp
98
111
  end
99
112
 
100
113
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bayserver-docker-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michisuke-P
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-23 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bayserver-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.2
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.2
26
+ version: 3.0.0
27
27
  description: BayServer is one of the high-speed web servers. It operates as a single-threaded,
28
28
  asynchronous server, which makes it exceptionally fast. It also supports multi-core
29
29
  processors, harnessing the full potential of the CPU's capabilities.
@@ -41,6 +41,7 @@ files:
41
41
  - lib/baykit/bayserver/docker/http/h1/h1_command.rb
42
42
  - lib/baykit/bayserver/docker/http/h1/h1_command_handler.rb
43
43
  - lib/baykit/bayserver/docker/http/h1/h1_command_unpacker.rb
44
+ - lib/baykit/bayserver/docker/http/h1/h1_handler.rb
44
45
  - lib/baykit/bayserver/docker/http/h1/h1_inbound_handler.rb
45
46
  - lib/baykit/bayserver/docker/http/h1/h1_packet.rb
46
47
  - lib/baykit/bayserver/docker/http/h1/h1_packet_factory.rb
@@ -64,6 +65,7 @@ files:
64
65
  - lib/baykit/bayserver/docker/http/h2/h2_command_unpacker.rb
65
66
  - lib/baykit/bayserver/docker/http/h2/h2_error_code.rb
66
67
  - lib/baykit/bayserver/docker/http/h2/h2_flags.rb
68
+ - lib/baykit/bayserver/docker/http/h2/h2_handler.rb
67
69
  - lib/baykit/bayserver/docker/http/h2/h2_inbound_handler.rb
68
70
  - lib/baykit/bayserver/docker/http/h2/h2_packet.rb
69
71
  - lib/baykit/bayserver/docker/http/h2/h2_packet_factory.rb