bayserver-docker-http 3.3.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a4d46496d23a37a8c5bc5f5852b379d0a901f5599aaaa502d949646c134e921
4
- data.tar.gz: b44a1b58fe21107515516a280654801e24f6cde5f7130b089f4c5d4882377259
3
+ metadata.gz: 77533775218a5eeece533642ac1268d650988959191835225d32c64169b0a22b
4
+ data.tar.gz: 1f84273c4d5308ed6f0a9f35304d87a3ac81f39bc82ca1e2f76b51cb9e42fc72
5
5
  SHA512:
6
- metadata.gz: f66955666f1fce85453badd1b76db78a3d3982c0a238e7a3c42c7acfdc8b2ec9420de309031212fa479b47dde6da288faacdafacbde87fb8ea4313a4ff13779d
7
- data.tar.gz: f304c2c88516c98712406769238d4c261bb637fc21d1d88b9f6d6701c20de967f4def4e1af3f6793015d6d7ac8e78d3a050dbb35db6bea7ab4eb413305238ccf
6
+ metadata.gz: 8843bca3e9b0468c6c2b3f3a92803c2f8246a670ac8f94258c3e4b73bc5a2cf959b0d6d8e86067bd3f8ef7fe58a69b910bd37a9156fe55de7df26db937603693
7
+ data.tar.gz: 589f8e2c5db82799fe851e78c1a42c35a51dd963f849aad53f3dad6d246293cd0baa5e7e6cdbd7f9b271e84a18a0cba531ef5b661ca289472dcf0d804c13651b
@@ -118,42 +118,48 @@ module Baykit
118
118
  end
119
119
 
120
120
  def unpack(pkt)
121
- acc = pkt.new_data_accessor
122
121
  data_len = pkt.data_len()
123
122
  state = STATE_READ_FIRST_LINE
124
123
 
125
124
  line_start_pos = 0
126
125
  line_len = 0
127
126
 
128
- data_len.times do |pos|
129
- b = acc.get_byte
130
- case b
131
- when CharUtil::CR_BYTE
132
- next
127
+ pos = 0
128
+ while pos < data_len
129
+ next_nl = pkt.buf.index("\n", pos)
130
+ if !next_nl
131
+ # No more new lines
132
+ break
133
+ end
133
134
 
134
- when CharUtil::LF_BYTE
135
- if line_len == 0
136
- break
137
- end
138
- if state == STATE_READ_FIRST_LINE
139
- if @is_req_header
140
- unpack_request_line(pkt.buf, line_start_pos, line_len)
141
- else
142
- unpack_status_line(pkt.buf, line_start_pos, line_len)
143
- end
144
-
145
- state = STATE_READ_MESSAGE_HEADERS
135
+ line_start_pos = pos
136
+
137
+ # Calculate line length excluding \n
138
+ # Also handle \r if it exists just before \n
139
+ line_end = (next_nl > pos && pkt.buf[next_nl - 1] == "\r") ? next_nl - 1 : next_nl
140
+ line_len = line_end - pos
141
+
142
+ if line_len == 0
143
+ # Empty line found (End of headers)
144
+ # Move pos past the newline and exit
145
+ pos = next_nl + 1
146
+ break
147
+ end
148
+
149
+ if state == STATE_READ_FIRST_LINE
150
+ if @is_req_header
151
+ unpack_request_line(pkt.buf, pos, line_len)
146
152
  else
147
- unpack_message_header(pkt.buf, line_start_pos, line_len)
153
+ unpack_status_line(pkt.buf, pos, line_len)
148
154
  end
149
155
 
150
- line_len = 0
151
- line_start_pos = pos + 1
152
-
156
+ state = STATE_READ_MESSAGE_HEADERS
153
157
  else
154
- line_len += 1
158
+ unpack_message_header(pkt.buf, pos, line_len)
155
159
  end
156
160
 
161
+ # Move to the start of the next line
162
+ pos = next_nl + 1
157
163
  end
158
164
 
159
165
  if state == STATE_READ_FIRST_LINE
@@ -257,11 +263,11 @@ module Baykit
257
263
  end
258
264
 
259
265
  def pack_request_line(acc)
260
- acc.put_string(@method)
266
+ acc.put_bytes(@method)
261
267
  acc.put_bytes(" ")
262
- acc.put_string(@uri)
268
+ acc.put_bytes(@uri)
263
269
  acc.put_bytes(" ")
264
- acc.put_string(@version);
270
+ acc.put_bytes(@version)
265
271
  acc.put_bytes(CharUtil::CRLF)
266
272
  end
267
273
 
@@ -276,9 +282,9 @@ module Baykit
276
282
 
277
283
  # status
278
284
  acc.put_bytes(" ")
279
- acc.put_string(@status.to_s)
285
+ acc.put_bytes(@status.to_s)
280
286
  acc.put_bytes(" ")
281
- acc.put_string(desc)
287
+ acc.put_bytes(desc)
282
288
  acc.put_bytes(CharUtil::CRLF)
283
289
  end
284
290
 
@@ -289,9 +295,9 @@ module Baykit
289
295
  if !value.kind_of?(String)
290
296
  raise RuntimeError.new("IllegalArgument: #{value}")
291
297
  end
292
- acc.put_string(name)
298
+ acc.put_bytes(name)
293
299
  acc.put_bytes(":")
294
- acc.put_string(value)
300
+ acc.put_bytes(value)
295
301
  acc.put_bytes(CharUtil::CRLF)
296
302
  end
297
303
 
@@ -139,7 +139,8 @@ module Baykit
139
139
  @protocol_handler.post(cmd, &callback)
140
140
  end
141
141
 
142
- def send_end_tour(tur, keep_alive, &callback)
142
+ def send_end_tour(tur, &callback)
143
+ keep_alive = tur.res.headers.get_connection() == Headers::CONNECTION_KEEP_ALIVE
143
144
  BayLog.trace("%s sendEndTour: tur=%s keep=%s", ship, tur, keep_alive)
144
145
 
145
146
  # Send dummy end request command
@@ -68,50 +68,45 @@ module Baykit
68
68
  suspend = false
69
69
 
70
70
  if @state == STATE_READ_HEADERS
71
- while pos < buf.length
72
- b = buf[pos]
73
- @tmp_buf.put_byte(b)
74
- pos += 1
75
- #@BayServer.info b + " " + b.codepoints[0].to_s + " pos=" + pos.to_s
76
- if b == CharUtil::CR
77
- next
78
- elsif b == CharUtil::LF
79
- if line_len == 0
80
- # empty line (all headers are read)
81
- pkt = @pkt_store.rent(H1Type::HEADER)
82
- pkt.new_data_accessor.put_bytes(@tmp_buf.bytes, 0, @tmp_buf.length)
83
-
84
- begin
85
- next_act = @cmd_upacker.packet_received(pkt)
86
- ensure
87
- @pkt_store.Return pkt
88
- end
89
-
90
- case next_act
91
- when NextSocketAction::CONTINUE, NextSocketAction::SUSPEND
92
- if @cmd_upacker.finished()
93
- change_state(STATE_END)
94
- else
95
- change_state(STATE_READ_CONTENT)
96
- end
97
- when NextSocketAction::CLOSE
98
- # Maybe error
99
- reset_state()
100
- return next_act
101
- else
102
- raise RuntimeError.new("Invalid next action: #{next_act}")
103
- end
104
-
105
- suspend = (next_act == NextSocketAction::SUSPEND)
106
- break
71
+
72
+ # Find end of headers (empty line)
73
+ # Look for \n\n (LF+LF) or \n\r\n (LF+CR+LF)
74
+ header_end_pos = buf.index("\n\r\n", pos) || buf.index("\n\n", pos)
75
+
76
+ if header_end_pos
77
+ # Calculate total header length
78
+ header_len = (buf[header_end_pos + 1] == "\r") ? header_end_pos + 3 : header_end_pos + 2
79
+
80
+ # Batch copy all header bytes at once
81
+ @tmp_buf.put(buf, pos, header_len - pos)
82
+ pos = header_len
83
+
84
+ # Move to packet processing
85
+ pkt = @pkt_store.rent(H1Type::HEADER)
86
+ pkt.new_data_accessor.put_bytes(@tmp_buf.bytes, 0, @tmp_buf.length)
87
+
88
+ begin
89
+ next_act = @cmd_upacker.packet_received(pkt)
90
+ ensure
91
+ @pkt_store.Return pkt
92
+ end
93
+
94
+ case next_act
95
+ when NextSocketAction::CONTINUE, NextSocketAction::SUSPEND
96
+ if @cmd_upacker.finished()
97
+ change_state(STATE_END)
98
+ else
99
+ change_state(STATE_READ_CONTENT)
107
100
  end
108
- line_len = 0
101
+ when NextSocketAction::CLOSE
102
+ # Maybe error
103
+ reset_state()
104
+ return next_act
109
105
  else
110
- line_len += 1
111
- end
112
- if line_len >= MAX_LINE_LEN
113
- raise ProtocolException.new("Http/1 Line is too long")
106
+ raise RuntimeError.new("Invalid next action: #{next_act}")
114
107
  end
108
+
109
+ suspend = (next_act == NextSocketAction::SUSPEND)
115
110
  end
116
111
  end
117
112
 
@@ -158,8 +158,8 @@ module Baykit
158
158
  @protocol_handler.post(cmd, &callback)
159
159
  end
160
160
 
161
- def send_end_tour(tur, keep_alive, &callback)
162
- BayLog.debug("%s send_end_tour. tur=%s keep=%s", self, tur, keep_alive)
161
+ def send_end_tour(tur, &callback)
162
+ BayLog.debug("%s send_end_tour. tur=%s", self, tur)
163
163
  cmd = CmdData.new(tur.req.key, nil, [], 0, 0)
164
164
  cmd.flags.set_end_stream(true)
165
165
  @protocol_handler.post(cmd, &callback)
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: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michisuke-P
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-01 00:00:00.000000000 Z
11
+ date: 2026-02-02 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: 3.3.1
19
+ version: 3.3.2
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: 3.3.1
26
+ version: 3.3.2
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.