File tree 5 files changed +117
-0
lines changed
rack-async-http-falcon-gzip
5 files changed +117
-0
lines changed Original file line number Diff line number Diff line change
1
+ source "https://rubygems.org"
2
+
3
+ gem "rack"
4
+ gem "falcon"
5
+ gem "async-http"
Original file line number Diff line number Diff line change
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ async (1.29.0 )
5
+ console (~> 1.10 )
6
+ nio4r (~> 2.3 )
7
+ timers (~> 4.1 )
8
+ async-container (0.16.8 )
9
+ async (~> 1.0 )
10
+ async-io (~> 1.26 )
11
+ async-http (0.56.1 )
12
+ async (~> 1.25 )
13
+ async-io (~> 1.28 )
14
+ async-pool (~> 0.2 )
15
+ protocol-http (~> 0.22.0 )
16
+ protocol-http1 (~> 0.14.0 )
17
+ protocol-http2 (~> 0.14.0 )
18
+ async-http-cache (0.4.0 )
19
+ async-http (~> 0.56 )
20
+ async-io (1.30.2 )
21
+ async (~> 1.14 )
22
+ async-pool (0.3.5 )
23
+ async (~> 1.25 )
24
+ build-environment (1.13.0 )
25
+ console (1.11.1 )
26
+ fiber-local
27
+ falcon (0.38.0 )
28
+ async (~> 1.13 )
29
+ async-container (~> 0.16.0 )
30
+ async-http (~> 0.56.0 )
31
+ async-http-cache (~> 0.4.0 )
32
+ async-io (~> 1.22 )
33
+ build-environment (~> 1.13 )
34
+ bundler
35
+ localhost (~> 1.1 )
36
+ process-metrics (~> 0.2.0 )
37
+ rack (>= 1.0 )
38
+ samovar (~> 2.1 )
39
+ fiber-local (1.0.0 )
40
+ localhost (1.1.7 )
41
+ mapping (1.1.1 )
42
+ nio4r (2.5.7 )
43
+ process-metrics (0.2.1 )
44
+ console (~> 1.8 )
45
+ samovar (~> 2.1 )
46
+ protocol-hpack (1.4.2 )
47
+ protocol-http (0.22.0 )
48
+ protocol-http1 (0.14.0 )
49
+ protocol-http (~> 0.22 )
50
+ protocol-http2 (0.14.2 )
51
+ protocol-hpack (~> 1.4 )
52
+ protocol-http (~> 0.18 )
53
+ rack (2.2.3 )
54
+ samovar (2.1.4 )
55
+ console (~> 1.0 )
56
+ mapping (~> 1.0 )
57
+ timers (4.3.3 )
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ async-http
64
+ falcon
65
+ rack
66
+
67
+ BUNDLED WITH
68
+ 2.1.4
Original file line number Diff line number Diff line change
1
+ Example app using:
2
+ * rack
3
+ * falcon
4
+ * async-http
5
+
6
+ Notes:
7
+ * Demo how to use ` Accept-Encoding: gzip `
8
+
9
+ Running:
10
+
11
+ falcon serve --count 1
Original file line number Diff line number Diff line change
1
+ require "async"
2
+ require "async/http/internet"
3
+
4
+ class App
5
+ def self . call ( env )
6
+ internet = Async ::HTTP ::Internet . new
7
+ url = "http://httpbin.org/gzip"
8
+
9
+ # headers can be a hash...
10
+ headers = {
11
+ "accept-encoding" => "gzip" ,
12
+ "user-agent" => "example" ,
13
+ }
14
+
15
+ # ...or an array...
16
+ headers = [
17
+ [ "accept-encoding" , "gzip" ] ,
18
+ [ "user-agent" , "example" ] ,
19
+ ]
20
+
21
+ response = internet . get ( url , headers )
22
+ body = JSON . parse ( response . read )
23
+
24
+ [ 200 , { } , [ body . to_json ] ]
25
+ end
26
+ end
Original file line number Diff line number Diff line change
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler . require
4
+
5
+ require_relative "app"
6
+
7
+ run App
You can’t perform that action at this time.
0 commit comments