async-http 0.27.3 → 0.27.4

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: 62159f76d28951cd1318ee83403215626a3e6a094fcccaec0f67ab4865f50ce4
4
- data.tar.gz: de18a9f234cacc5943468cc9454e8bb8102c3dac38a81129b0dc9cebc1820368
3
+ metadata.gz: d6fe0971913f89e9ebd68515c2e93ae525757490c52d36ab1b28a6ecc6f1257f
4
+ data.tar.gz: aa2e52fada5c8e31e634d40f84eca6fe4f4fa604eb7eeb220e7b020a8fdeb4cf
5
5
  SHA512:
6
- metadata.gz: dd79c554a941ba4e0d33221c642a003b90c8459faf3a8a8c025fdeb9f5ef03db9f30f4ff37ce3b26511447b5b903c96783f8109b4689ba417779dccc3e0b5b20
7
- data.tar.gz: e807c841615de91a7d97c20a47c80c1c9e30246980d1ff627f4c88486d147d8108e1d1cd953928b0a02e350fbc95a88e45c053e5601ad5625bc62de431b40981
6
+ metadata.gz: 44a409a36d515ff781392703c8daa76984f02f56ff6860f86939fa8740adf940d9ac313a2b5436afc3939e4162c46fd56c7e19518071992b9637d3bac703cd92
7
+ data.tar.gz: b4b2869437271dda4f1dbf748c852fd6ac8d4f0e2e1aa3e3c495601a25e9fdf121562325c61436b2ca1de3a92551437e3403409a028a7373e7ab722f41838c72
@@ -85,6 +85,7 @@ module Async
85
85
  end
86
86
  end
87
87
 
88
+ # @return [Async::Wrapper] the underlying non-blocking IO.
88
89
  def hijack
89
90
  @persistent = false
90
91
 
@@ -130,15 +131,22 @@ module Async
130
131
  # Server loop.
131
132
  def receive_requests(task: Task.current)
132
133
  while request = next_request
133
- if response = yield(request, self)
134
+ response = yield(request, self)
135
+
136
+ return if @stream.closed?
137
+
138
+ if response
134
139
  write_response(self.version, response.status, response.headers, response.body)
135
- request.finish
136
-
137
- # This ensures we yield at least once every iteration of the loop and allow other fibers to execute.
138
- task.yield
139
140
  else
140
- break
141
+ # If the request failed to generate a response, it was an internal server error:
142
+ write_response(self.version, 500, {}, nil)
141
143
  end
144
+
145
+ # Gracefully finish reading the request body if it was not already done so.
146
+ request.finish
147
+
148
+ # This ensures we yield at least once every iteration of the loop and allow other fibers to execute.
149
+ task.yield
142
150
  end
143
151
  end
144
152
 
@@ -235,7 +235,7 @@ module Async
235
235
  stream.data("", end_stream: true)
236
236
  end
237
237
  else
238
- stream.close(:internal_error) unless stream.state == :closed
238
+ stream.headers({':status' => '500'}, end_stream: true)
239
239
  end
240
240
  rescue
241
241
  Async.logger.error(request) {$!}
@@ -64,6 +64,10 @@ module Async
64
64
  status == 400
65
65
  end
66
66
 
67
+ def server_failure?
68
+ status == 500
69
+ end
70
+
67
71
  def self.[](status, headers = {}, body = [])
68
72
  body = Body::Buffered.wrap(body)
69
73
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.27.3"
23
+ VERSION = "0.27.4"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.3
4
+ version: 0.27.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-29 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async