tipi 0.51 → 0.52

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: 6338c894cec0a59a270a7c75535441ab6be2c8a6fbb5457b8ecfd200ade25b92
4
- data.tar.gz: 620303ca676af631574e678ca8e43f3af679d6c2dddbaeb29b1a1e3c3f3fe716
3
+ metadata.gz: efec664af01dfb4781c30670e2471a591a6c8df3a8024b5f14dc4edded3f5c1d
4
+ data.tar.gz: 0f384c5a305c5afe524b9a0e28d2a06931340275fe879e963cc194d2cde3c766
5
5
  SHA512:
6
- metadata.gz: 2fc80e081f7f933ab2f2f352aae042e0cd396942b460c2061a6064b2ba90c31011c8e8632a3abebc17c8904b7406164b9771d2a0645b868a6de0d79b0a296c67
7
- data.tar.gz: 295b6f82fc7a1bbc4e5b15e8c49732aa05d66b0b366ad93aa310c17b7be727a71f179f68358e5905d06efa29ad0b2f8a95d948f7625ea9455dac74b1b32f023e
6
+ metadata.gz: 7aa3995cd7ad560f3ba0f8a318da6c5ef62d53bc02209f05491f1e3db5b140e2697e8cd3158686a62c3dbae373d0260d803befabf4b8c417e862f2e6f68860bf
7
+ data.tar.gz: 7a17368c2fd9572531ac137822727082e48b85322190b91197f699d34d0554fd39d5dc7a18fe6f68bf8ea64dadbabbb464f39fa2b83475ee52cee99484c422a5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.52 2022-03-03
2
+
3
+ - Treat HTTP/2 headers as immutable
4
+
1
5
  ## 0.51 2022-02-28
2
6
 
3
7
  - Update dependencies
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tipi (0.51)
4
+ tipi (0.52)
5
5
  acme-client (~> 2.0.9)
6
6
  ever (~> 0.1)
7
7
  extralite (~> 1.14)
@@ -56,7 +56,7 @@ GEM
56
56
  minitest (5.11.3)
57
57
  msgpack (1.4.5)
58
58
  multipart-post (2.1.1)
59
- polyphony (0.80)
59
+ polyphony (0.81)
60
60
  qeweney (0.18)
61
61
  escape_utils (~> 1.2.1)
62
62
  rack (2.2.3)
@@ -113,21 +113,19 @@ module Tipi
113
113
  end
114
114
 
115
115
  # response API
116
- def respond(request, chunk, headers)
117
- headers[':status'] ||= Qeweney::Status::OK
118
- headers[':status'] = headers[':status'].to_s
116
+ def respond(request, body, headers)
117
+ headers = normalize_status_header(headers)
119
118
  with_transfer_count(request) do
120
119
  @stream.headers(transform_headers(headers))
121
120
  @headers_sent = true
122
- @stream.data(chunk || '')
121
+ @stream.data(body || '')
123
122
  end
124
123
  rescue HTTP2::Error::StreamClosed
125
124
  # ignore
126
125
  end
127
126
 
128
127
  def respond_from_io(request, io, headers, chunk_size = 2**16)
129
- headers[':status'] ||= Qeweney::Status::OK
130
- headers[':status'] = headers[':status'].to_s
128
+ headers = normalize_status_header(headers)
131
129
  with_transfer_count(request) do
132
130
  @stream.headers(transform_headers(headers))
133
131
  @headers_sent = true
@@ -152,7 +150,8 @@ module Tipi
152
150
  def send_headers(request, headers, empty_response: false)
153
151
  return if @headers_sent
154
152
 
155
- headers[':status'] ||= (empty_response ? Qeweney::Status::NO_CONTENT : Qeweney::Status::OK).to_s
153
+ status = empty_response ? Qeweney::Status::NO_CONTENT : Qeweney::Status::OK
154
+ headers = normalize_status_header(headers, status)
156
155
  with_transfer_count(request) do
157
156
  @stream.headers(transform_headers(headers), end_stream: false)
158
157
  end
@@ -194,5 +193,17 @@ module Tipi
194
193
  @stream.close
195
194
  @stream_fiber.schedule(Polyphony::MoveOn.new)
196
195
  end
196
+
197
+ private
198
+
199
+ def normalize_status_header(headers, default_status = Qeweney::Status::OK)
200
+ if !headers[':status']
201
+ headers.merge(':status' => default_status.to_s)
202
+ elsif !headers[':status'].is_a?(String)
203
+ headers.merge(headers[':status'].to_s)
204
+ else
205
+ headers
206
+ end
207
+ end
197
208
  end
198
209
  end
data/lib/tipi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tipi
4
- VERSION = '0.51'
4
+ VERSION = '0.52'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tipi
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.51'
4
+ version: '0.52'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-28 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: polyphony