falcon 0.36.4 → 0.37.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/falcon/adapters/input.rb +32 -11
  3. data/lib/falcon/adapters/output.rb +20 -1
  4. data/lib/falcon/adapters/rack.rb +60 -39
  5. data/lib/falcon/adapters/response.rb +23 -1
  6. data/lib/falcon/adapters/rewindable.rb +10 -3
  7. data/lib/falcon/command.rb +2 -0
  8. data/lib/falcon/command/host.rb +22 -3
  9. data/lib/falcon/command/paths.rb +4 -0
  10. data/lib/falcon/command/proxy.rb +14 -0
  11. data/lib/falcon/command/redirect.rb +12 -0
  12. data/lib/falcon/command/serve.rb +27 -16
  13. data/lib/falcon/command/supervisor.rb +15 -1
  14. data/lib/falcon/command/top.rb +16 -0
  15. data/lib/falcon/command/virtual.rb +15 -0
  16. data/lib/falcon/configuration.rb +69 -7
  17. data/lib/falcon/controller/host.rb +12 -0
  18. data/lib/falcon/controller/proxy.rb +13 -0
  19. data/lib/falcon/controller/redirect.rb +7 -0
  20. data/lib/falcon/controller/serve.rb +17 -2
  21. data/lib/falcon/controller/virtual.rb +17 -0
  22. data/lib/falcon/endpoint.rb +8 -0
  23. data/lib/falcon/{configuration/proxy.rb → environments.rb} +9 -5
  24. data/lib/falcon/environments/application.rb +72 -0
  25. data/lib/falcon/{configuration/application.rb → environments/lets_encrypt_tls.rb} +21 -20
  26. data/lib/falcon/{configuration/lets_encrypt_tls.rb → environments/proxy.rb} +13 -6
  27. data/lib/falcon/{configuration → environments}/rack.rb +14 -2
  28. data/lib/falcon/{configuration → environments}/self_signed_tls.rb +9 -1
  29. data/lib/falcon/{configuration → environments}/supervisor.rb +19 -5
  30. data/lib/falcon/{configuration → environments}/tls.rb +39 -5
  31. data/lib/falcon/extensions/openssl.rb +1 -0
  32. data/lib/falcon/middleware/proxy.rb +26 -5
  33. data/lib/falcon/middleware/redirect.rb +11 -0
  34. data/lib/falcon/{verbose.rb → middleware/verbose.rb} +34 -26
  35. data/lib/falcon/proxy_endpoint.rb +21 -0
  36. data/lib/falcon/server.rb +8 -2
  37. data/lib/falcon/service/application.rb +24 -2
  38. data/lib/falcon/service/generic.rb +18 -0
  39. data/lib/falcon/service/proxy.rb +6 -0
  40. data/lib/falcon/service/supervisor.rb +13 -1
  41. data/lib/falcon/services.rb +21 -0
  42. data/lib/falcon/tls.rb +4 -2
  43. data/lib/falcon/version.rb +1 -1
  44. data/lib/rack/handler/falcon.rb +8 -2
  45. metadata +64 -121
  46. data/.editorconfig +0 -5
  47. data/.github/FUNDING.yml +0 -3
  48. data/.github/workflows/development.yml +0 -60
  49. data/.gitignore +0 -14
  50. data/.rspec +0 -3
  51. data/Gemfile +0 -17
  52. data/README.md +0 -316
  53. data/examples/beer/config.ru +0 -57
  54. data/examples/beer/falcon.rb +0 -8
  55. data/examples/benchmark/config.ru +0 -39
  56. data/examples/benchmark/falcon.rb +0 -6
  57. data/examples/csv/config.ru +0 -31
  58. data/examples/google/falcon.rb +0 -14
  59. data/examples/hello/config.ru +0 -22
  60. data/examples/hello/falcon.rb +0 -24
  61. data/examples/hello/preload.rb +0 -7
  62. data/examples/internet/config.ru +0 -54
  63. data/examples/memory/allocations.rb +0 -39
  64. data/examples/memory/config.ru +0 -14
  65. data/examples/push/client.rb +0 -29
  66. data/examples/push/config.ru +0 -28
  67. data/examples/push/index.html +0 -14
  68. data/examples/push/script.js +0 -2
  69. data/examples/push/style.css +0 -4
  70. data/examples/redis/Gemfile +0 -9
  71. data/examples/redis/config.ru +0 -28
  72. data/examples/sequel/Gemfile +0 -4
  73. data/examples/sequel/config.ru +0 -8
  74. data/examples/sequel/data.sqlite3 +0 -0
  75. data/examples/server/standalone.rb +0 -27
  76. data/examples/sinatra/Gemfile +0 -7
  77. data/examples/sinatra/Gemfile.lock +0 -53
  78. data/examples/sinatra/config.ru +0 -16
  79. data/examples/trailers/config.ru +0 -34
  80. data/examples/trailers/falcon.rb +0 -8
  81. data/falcon.gemspec +0 -45
  82. data/gems/rack1.gemfile +0 -4
  83. data/gems/rack3.gemfile +0 -4
  84. data/lib/falcon/adapters/early_hints.rb +0 -49
  85. data/logo-square.afdesign +0 -0
  86. data/logo.afdesign +0 -0
  87. data/logo.svg +0 -107
  88. data/server.rb +0 -21
  89. data/tasks/benchmark.rake +0 -103
@@ -1,5 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
@@ -1,3 +0,0 @@
1
- # These are supported funding model platforms
2
- custom: https://github.com/socketry/community/#funding
3
- github: ioquatix
@@ -1,60 +0,0 @@
1
- name: Development
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ${{matrix.os}}-latest
8
- continue-on-error: ${{matrix.experimental}}
9
-
10
- strategy:
11
- matrix:
12
- experimental: [false]
13
-
14
- os:
15
- - ubuntu
16
- - macos
17
-
18
- ruby:
19
- - 2.5
20
- - 2.6
21
- - 2.7
22
-
23
- include:
24
- # - experimental: true
25
- # os: ubuntu
26
- # ruby: truffleruby
27
- # - experimental: true
28
- # os: ubuntu
29
- # ruby: jruby
30
- - experimental: true
31
- os: ubuntu
32
- ruby: head
33
- - experimental: true
34
- os: ubuntu
35
- ruby: 2.7
36
- env: BUNDLE_GEMFILE=gems/rack1.gemfile
37
- - experimental: true
38
- os: ubuntu
39
- ruby: 2.7
40
- env: BUNDLE_GEMFILE=gems/rack3.gemfile
41
- - experimental: true
42
- os: ubuntu
43
- ruby: 2.6
44
- env: COVERAGE=PartialSummary,Coveralls
45
-
46
- steps:
47
- - uses: actions/checkout@v1
48
- - uses: ruby/setup-ruby@v1
49
- with:
50
- ruby-version: ${{matrix.ruby}}
51
-
52
- - name: Installing packages (ubuntu)
53
- if: matrix.os == 'ubuntu'
54
- run: sudo apt-get install apache2-utils
55
-
56
- - name: Install dependencies
57
- run: ${{matrix.env}} bundle install
58
-
59
- - name: Run tests
60
- run: ${{matrix.env}} bundle exec rspec
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- .tags
2
-
3
- /.bundle/
4
- /.yardoc
5
- /Gemfile.lock
6
- /_yardoc/
7
- /coverage/
8
- /doc/
9
- /pkg/
10
- /spec/reports/
11
- /tmp/
12
-
13
- .rspec_status
14
- .covered.db
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper
data/Gemfile DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- # gem "async-container", path: "../async-container"
8
- # gem "async-websocket", path: "../async-websocket"
9
- # gem "async-http", path: "../async-http"
10
-
11
- group :development do
12
- gem 'ruby-prof', platform: :mri
13
- end
14
-
15
- group :test do
16
- gem 'puma'
17
- end
data/README.md DELETED
@@ -1,316 +0,0 @@
1
- # ![Falcon](logo.svg)
2
-
3
- Falcon is a multi-process, multi-fiber rack-compatible HTTP server built on top of [async], [async-io], [async-container] and [async-http]. Each request is executed within a lightweight fiber and can block on up-stream requests without stalling the entire server process. Falcon supports HTTP/1 and HTTP/2 natively.
4
-
5
- [Priority Business Support](#priority-business-support) is available.
6
-
7
- [![Actions Status](https://github.com/socketry/falcon/workflows/Development/badge.svg)](https://github.com/socketry/falcon/actions?workflow=Development)
8
- [![Code Climate](https://codeclimate.com/github/socketry/falcon.svg)](https://codeclimate.com/github/socketry/falcon)
9
- [![Coverage Status](https://coveralls.io/repos/socketry/falcon/badge.svg)](https://coveralls.io/r/socketry/falcon)
10
- [![Gitter](https://badges.gitter.im/join.svg)](https://gitter.im/socketry/falcon)
11
- [![Open Source Helpers](https://www.codetriage.com/socketry/falcon/badges/users.svg)](https://www.codetriage.com/socketry/falcon)
12
-
13
- [async]: https://github.com/socketry/async
14
- [async-io]: https://github.com/socketry/async-io
15
- [async-container]: https://github.com/socketry/async-container
16
- [async-http]: https://github.com/socketry/async-http
17
-
18
- ## Motivation
19
-
20
- Initially, when I developed [async], I saw an opportunity to implement [async-http]: providing both client and server components. After experimenting with these ideas, I decided to build an actual web server for comparing and validating performance primarily out of interest. Falcon grew out of those experiments and permitted the ability to test existing real-world code on top of [async].
21
-
22
- Once I had something working, I saw an opportunity to simplify my development, testing and production environments, replacing production (Nginx+Passenger) and development (Puma) with Falcon. Not only does this simplify deployment, it helps minimize environment-specific bugs.
23
-
24
- My long term vision for Falcon is to make a web application platform which trivializes server deployment. Ideally, a web application can fully describe all it's components: HTTP servers, databases, periodic jobs, background jobs, remote management, etc. Currently, it is not uncommon for all these facets to be handled independently in platform specific ways. This can make it difficult to set up new instances as well as make changes to underlying infrastructure. I hope Falcon can address some of these issues in a platform agnostic way.
25
-
26
- As web development is something I'm passionate about, having a server like Falcon is empowering.
27
-
28
- ## Installation
29
-
30
- Add this line to your application's Gemfile:
31
-
32
- ```ruby
33
- gem 'falcon'
34
- ```
35
-
36
- And then execute:
37
-
38
- $ bundle
39
-
40
- Alternatively, install in terminal:
41
-
42
- $ gem install falcon
43
-
44
- ## Usage
45
-
46
- ### Development
47
-
48
- You can run `falcon serve` directly. It will load the `config.ru` and start serving on https://localhost:9292. Please [try the interactive online tutorial](https://katacoda.com/ioquatix/scenarios/falcon-introduction).
49
-
50
- To run on a different port:
51
-
52
- ```
53
- $ falcon serve --port 3000
54
- ```
55
-
56
- ### Production
57
-
58
-
59
-
60
- ### Virtual Hosts
61
-
62
- Falcon can replace Nginx as a virtual server for Ruby applications. **This is an experimental feature**.
63
-
64
- ```
65
- /--------------------\
66
- | Client Browser |
67
- \--------------------/
68
- ||
69
- (TLS + HTTP/2 TCP)
70
- ||
71
- /--------------------\
72
- | Falcon Proxy (SNI) |
73
- \--------------------/
74
- ||
75
- (HTTP/2 UNIX PIPE)
76
- ||
77
- /--------------------\
78
- | Application Server | (Rack Compatible)
79
- \--------------------/
80
- ```
81
-
82
- You need to create a `falcon.rb` configuration in the root of your application, and start the virtual host:
83
-
84
- ```
85
- $ cat /srv/http/example.com/falcon.rb
86
- #!/usr/bin/env -S falcon host
87
-
88
- load :rack, :lets_encrypt_tls, :supervisor
89
-
90
- rack 'hello.localhost', :lets_encrypt_tls
91
-
92
- supervisor
93
-
94
- % falcon virtual /srv/http/example.com/falcon.rb
95
- ```
96
-
97
- The falcon virtual server is hard coded to redirect http traffic to https, and will serve each application using an internal SNI-based proxy.
98
-
99
- ### Integration with Rails
100
-
101
- Falcon works perfectly with `rails` apps.
102
-
103
- 1. Add `gem 'falcon'` to your `Gemfile` and perhaps remove `gem 'puma'` once you are satisfied with the change.
104
-
105
- 2. Run `falcon serve` to start a local development server.
106
-
107
- Alternatively run `RACK_HANDLER=falcon rails server` to start the server (at least, until [rack#1181](https://github.com/rack/rack/pull/1181) is merged).
108
-
109
- #### Thread Safety
110
-
111
- With older versions of Rails, the `Rack::Lock` middleware can be inserted into your app by Rails. `Rack::Lock`will cause both poor performance and deadlocks due to the highly concurrent nature of `falcon`. Other web frameworks are generally unaffected.
112
-
113
- ##### Rails 3.x (and older)
114
-
115
- Please ensure you specify `config.threadsafe!` in your `config/application.rb`:
116
-
117
- ```ruby
118
- module MySite
119
- class Application < Rails::Application
120
- # ...
121
-
122
- # Enable threaded mode
123
- config.threadsafe!
124
- end
125
- end
126
- ```
127
-
128
- ##### Rails 4.x
129
-
130
- Please ensure you have `config.allow_concurrency = true` in your configuration.
131
-
132
- ##### Rails 5.x+
133
-
134
- This became the default in Rails 5 so no change is necessary unless you explicitly disabled concurrency, in which case you should remove that configuration.
135
-
136
- ### WebSockets
137
-
138
- Falcon supports (partial and full) `rack.hijack` for both for HTTP/1 and HTTP/2 connections. You can thus use [async-websocket] in any controller layer to serve WebSocket connections.
139
-
140
- [async-websocket]: https://github.com/socketry/async-websocket
141
-
142
- #### ActionCable
143
-
144
- The `rack.hijack` functionality is compatible with ActionCable. If you use the `async` adapter, you should run falcon in threaded mode, or in forked mode with `--count 1`. Otherwise, your messaging system will be distributed over several processes with no IPC mechanism. You might like to try out [async-redis](https://github.com/socketry/async-redis) as an asynchronous message bus.
145
-
146
- ### Early Hints
147
-
148
- Falcon supports the `rack.early_hints` API when running over HTTP/2.
149
-
150
- ### Integration with Guard
151
-
152
- Falcon can restart very quickly and is ideal for use with guard. See [guard-falcon] for more details.
153
-
154
- [guard-falcon]: https://github.com/socketry/guard-falcon
155
-
156
- ### Integration with Capybara
157
-
158
- Falcon can run in the same process on a different thread, so it's great for use with Capybara (and shared ActiveRecord transactions). See [falcon-capybara] for more details.
159
-
160
- [falcon-capybara]: https://github.com/socketry/falcon-capybara
161
-
162
- ### Using with Rackup
163
-
164
- You can invoke Falcon via `rackup`:
165
-
166
- rackup --server falcon
167
-
168
- This will run a single-threaded instance of Falcon using `http/1`. While it works fine, it's not recommended to use `rackup` with `falcon`, because performance will be limited.
169
-
170
- ### Self-Signed TLS with Curl
171
-
172
- In order to use `curl` with self-signed localhost certificates, you need to specify `--insecure` or the path of the certificate to validate the request:
173
-
174
- ```
175
- > curl -v https://localhost:9292 --cacert ~/.localhost/localhost.crt
176
- * Trying ::1...
177
- * TCP_NODELAY set
178
- * Connected to localhost (::1) port 9292 (#0)
179
- * ALPN, offering http/1.1
180
- * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
181
- * successfully set certificate verify locations:
182
- * CAfile: /Users/samuel/.localhost/localhost.crt
183
- CApath: none
184
- * TLSv1.2 (OUT), TLS header, Certificate Status (22):
185
- * TLSv1.2 (OUT), TLS handshake, Client hello (1):
186
- * TLSv1.2 (IN), TLS handshake, Server hello (2):
187
- * TLSv1.2 (IN), TLS handshake, Certificate (11):
188
- * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
189
- * TLSv1.2 (IN), TLS handshake, Request CERT (13):
190
- * TLSv1.2 (IN), TLS handshake, Server finished (14):
191
- * TLSv1.2 (OUT), TLS handshake, Certificate (11):
192
- * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
193
- * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
194
- * TLSv1.2 (OUT), TLS handshake, Finished (20):
195
- * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
196
- * TLSv1.2 (IN), TLS handshake, Finished (20):
197
- * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
198
- * ALPN, server accepted to use http/1.1
199
- * Server certificate:
200
- * subject: O=Development/CN=localhost
201
- * start date: Aug 10 00:31:43 2018 GMT
202
- * expire date: Aug 7 00:31:43 2028 GMT
203
- * subjectAltName: host "localhost" matched cert's "localhost"
204
- * issuer: O=Development/CN=localhost
205
- * SSL certificate verify ok.
206
- > GET / HTTP/1.1
207
- > Host: localhost:9292
208
- > User-Agent: curl/7.63.0
209
- > Accept: */*
210
- >
211
- < HTTP/1.1 301
212
- < location: /index
213
- < cache-control: max-age=86400
214
- < content-length: 0
215
- <
216
- * Connection #0 to host localhost left intact
217
- ```
218
-
219
- ## Performance
220
-
221
- Falcon uses an asynchronous event-driven reactor to provide non-blocking IO. It can handle an arbitrary number of in-flight requests with minimal overhead per request.
222
-
223
- It uses one Fiber per request, which yields in the presence of blocking IO.
224
-
225
- - [Improving Ruby Concurrency](https://www.codeotaku.com/journal/2018-06/improving-ruby-concurrency/index#performance) – Comparison of Falcon and Puma.
226
-
227
- ### Memory Usage
228
-
229
- Falcon uses a pre-fork model which loads the entire rack application before forking. This reduces per-process memory usage.
230
-
231
- [async-http] has been designed carefully to minimize IO related garbage. This avoids large per-request memory allocations or disk usage, provided that you use streaming IO.
232
-
233
- ### System Limitations
234
-
235
- If you are expecting to handle many simultaneous connections, please ensure you configure your file limits correctly.
236
-
237
- ```
238
- Errno::EMFILE: Too many open files - accept(2)
239
- ```
240
-
241
- This means that your system is limiting the number of files that can be opened by falcon. Please check the `ulimit` of your system and set it appropriately.
242
-
243
- ## Priority Business Support
244
-
245
- Falcon can be an important part of your business or project, both improving performance and saving money. As such, priority business support is available to make every project a success. The agreement will give you:
246
-
247
- - Better software by funding development and testing.
248
- - Access to "Stretch" goals as outlined below.
249
- - Advance notification of bugs and security issues.
250
- - Priority consideration of feature requests and bug reports.
251
- - Private support and assistance via direct email.
252
-
253
- The standard price for business support is $120.00 USD / year / production instance (including reserve instances). Please [contact us](mailto:contact@oriontransfer.net?subject=Falcon%20Business%20Support) for more details.
254
-
255
- ### "Stretch" Goals
256
-
257
- Each paying business customer is entitled to one vote to prioritize the below work.
258
-
259
- - Add support stream prioritization in [async-http].
260
- - Add support for rolling restarts in [async-container].
261
- - Add support for hybrid process/thread model in [async-container].
262
- - Asynchronous Postgres and MySQL database adapters for ActiveRecord in [async-postgres] and [async-mysql].
263
-
264
- [async-http]: https://github.com/socketry/async-http
265
- [async-container]: https://github.com/socketry/async-container
266
- [async-postgres]: https://github.com/socketry/async-postgres
267
- [async-mysql]: https://github.com/socketry/async-mysql
268
-
269
- ## Contributing
270
-
271
- 1. Fork it
272
- 2. Create your feature branch (`git checkout -b my-new-feature`)
273
- 3. Commit your changes (`git commit -am 'Add some feature'`)
274
- 4. Push to the branch (`git push origin my-new-feature`)
275
- 5. Create new Pull Request
276
-
277
- ### Donations
278
-
279
- If you want to donate to this project, you may do so using [BitCoin](https://www.blockchain.com/btc/payment_request?address=1BU3RnjB7fS9XmiTHgbmLKL36S5kccovs8). All money donated this way will be used to further development of this and related open source projects.
280
-
281
- ### Responsible Disclosure
282
-
283
- We take the security of our systems seriously, and we value input from the security community. The disclosure of security vulnerabilities helps us ensure the security and privacy of our users. If you believe you've found a security vulnerability in one of our products or platforms please [tell us via email](mailto:security@oriontransfer.net).
284
-
285
- ## Websites using Falcon
286
-
287
- Websites below are listed in alphabetical order.
288
-
289
- - iCook - [https://icook.tw](https://icook.tw)
290
- - RubyAPI - [https://rubyapi.org](https://rubyapi.org)
291
-
292
- You're welcome to file a PR if you want to add your sites here.
293
-
294
- ## License
295
-
296
- Released under the MIT license.
297
-
298
- Copyright, 2018, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
299
-
300
- Permission is hereby granted, free of charge, to any person obtaining a copy
301
- of this software and associated documentation files (the "Software"), to deal
302
- in the Software without restriction, including without limitation the rights
303
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
304
- copies of the Software, and to permit persons to whom the Software is
305
- furnished to do so, subject to the following conditions:
306
-
307
- The above copyright notice and this permission notice shall be included in
308
- all copies or substantial portions of the Software.
309
-
310
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
311
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
312
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
313
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
314
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
315
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
316
- THE SOFTWARE.
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env falcon --verbose serve -c
2
- # frozen_string_literal: true
3
-
4
- require 'rack'
5
- require 'cgi'
6
-
7
- def bottles(n)
8
- n == 1 ? "#{n} bottle" : "#{n} bottles"
9
- end
10
-
11
- # Browsers don't show streaming content until a certain threshold has been met. For most browers, it's about 1024 bytes. So, we have a comment of about that length which we feed to the client before streaming actual content. For more details see https://stackoverflow.com/questions/16909227
12
- COMMENT = "<!--#{'-' * 1024}-->"
13
-
14
- # To test this example with the curl command-line tool, you'll need to add the `--no-buffer` flag or set the COMMENT size to the required 4096 bytes in order for curl to start streaming.
15
- # curl http://localhost:9292/ --no-buffer
16
-
17
- run lambda {|env|
18
- task = Async::Task.current
19
- body = Async::HTTP::Body::Writable.new
20
-
21
- request = Rack::Request.new(env)
22
- count = (request.params['count'] || 99).to_i
23
-
24
- body.write("<!DOCTYPE html><html><head><title>#{count} Bottles of Beer</title></head><body>")
25
-
26
- task.async do |task|
27
- begin
28
- body.write(COMMENT)
29
-
30
- count.downto(1) do |i|
31
- task.annotate "bottles of beer #{i}"
32
-
33
- Async.logger.info(body) {"#{bottles(i)} of beer on the wall..."}
34
- body.write("<p>#{bottles(i)} of beer on the wall, ")
35
- task.sleep(0.1)
36
- body.write("#{bottles(i)} of beer, ")
37
- task.sleep(0.1)
38
- body.write("take one down and pass it around, ")
39
- task.sleep(0.1)
40
- body.write("#{bottles(i-1)} of beer on the wall.</p>")
41
- task.sleep(0.1)
42
- body.write("<script>var child; while (child = document.body.firstChild) child.remove();</script>")
43
- end
44
-
45
- code = File.read(__FILE__)
46
- body.write("<h1>Source Code</h1>")
47
- body.write("<pre><code>#{CGI.escapeHTML code}</code></pre>")
48
- body.write("</body></html>")
49
- rescue
50
- puts "Remote end closed connection: #{$!}"
51
- ensure
52
- body.close
53
- end
54
- end
55
-
56
- [200, {'content-type' => 'text/html; charset=utf-8'}, body]
57
- }