httpkit 0.6.0.pre.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +0 -2
  3. data/.travis.yml +1 -1
  4. data/Gemfile +2 -0
  5. data/README.md +32 -25
  6. data/Rakefile +5 -0
  7. data/config/flay.yml +1 -1
  8. data/doc/api/httpkit.html +50 -0
  9. data/doc/api/httpkit/body.html +149 -0
  10. data/doc/api/httpkit/client.html +50 -0
  11. data/doc/api/httpkit/client/body_handler.html +50 -0
  12. data/doc/api/httpkit/client/keep_alive_handler.html +79 -0
  13. data/doc/api/httpkit/client/mandatory_handler.html +50 -0
  14. data/doc/api/httpkit/client/timeouts_handler.html +82 -0
  15. data/doc/api/httpkit/connection/eventmachine.html +157 -0
  16. data/doc/api/httpkit/connection/status.html +50 -0
  17. data/doc/api/httpkit/promise.html +50 -0
  18. data/doc/api/httpkit/request.html +123 -0
  19. data/doc/api/httpkit/response.html +209 -0
  20. data/doc/api/httpkit/serializer.html +150 -0
  21. data/doc/api/httpkit/server.html +50 -0
  22. data/doc/api/httpkit/server/block_handler.html +50 -0
  23. data/doc/api/httpkit/server/body_handler.html +50 -0
  24. data/doc/api/httpkit/server/keep_alive_handler.html +145 -0
  25. data/doc/api/httpkit/server/mandatory_handler.html +50 -0
  26. data/doc/api/httpkit/server/timeouts_handler.html +81 -0
  27. data/doc/api/httpkit/support/handler_manager.html +95 -0
  28. data/doc/api/httpkit/support/message.html +50 -0
  29. data/doc/api/httpkit/version.html +50 -0
  30. data/doc/examples/echo_server.html +101 -0
  31. data/doc/examples/error_handling.html +176 -0
  32. data/doc/examples/getting_started.html +161 -0
  33. data/doc/examples/streaming.html +108 -0
  34. data/doc/index.html +165 -0
  35. data/examples/echo_server.rb +14 -6
  36. data/examples/error_handling.rb +56 -0
  37. data/examples/getting_started.rb +10 -18
  38. data/examples/streaming.rb +41 -0
  39. data/lib/httpkit.rb +22 -0
  40. data/lib/httpkit/body.rb +4 -0
  41. data/lib/httpkit/client.rb +1 -9
  42. data/lib/httpkit/client/keep_alive_handler.rb +1 -0
  43. data/lib/httpkit/connection/eventmachine.rb +2 -1
  44. data/lib/httpkit/server/block_handler.rb +13 -0
  45. data/lib/httpkit/server/keep_alive_handler.rb +1 -0
  46. data/lib/httpkit/version.rb +1 -1
  47. data/spec/integration/timeouts_spec.rb +3 -2
  48. data/spec/support/helper.rb +1 -8
  49. data/spec/unit/client_spec.rb +2 -21
  50. data/spec/unit/server_spec.rb +11 -1
  51. metadata +34 -5
  52. data/Procfile +0 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjQ5NTA0NGVmZTllMzYyZDQ2NmFlMGFkMTRiNzZhNWIwMjY3MzQ2Mw==
4
+ MzhkZDBkNGQzMTk3NjZhZmM0ZDc3MTViZmI5Yzk3ZDg5ODRiNTVhNg==
5
5
  data.tar.gz: !binary |-
6
- OWU0MTU3ZGZmYmE3OWVjZjRlOTZjZGYzMTU2MWFiNmQ5OWUxMTczNQ==
6
+ ODcyMDMyNTJmOTAwMzE1MmViZGI0MDdhOWYxMTQwZWYwMzhkZjVjZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTYyYTczNzczNDA4YWFiMGIwZDE0ZTBkYzcxY2E3NWEwMGM5OTE1Yzg4ZDY2
10
- YzI5NWMxY2IxMDA5MjEzNDI0MTU4NDA4NTFlMjljNGYxZDg1YzM3ZWQ1MjE3
11
- YWQzYmViMmJhM2QxYmE1ZDI5YTFiOTYwYTI4YjAxMjhlMDkxYjQ=
9
+ M2RmMDRiZWVmNDY1NmM5NGE3OWU2YmNhYWY1ZWM1MTY3Mzc0NWMwMWNjM2E4
10
+ MzYwYWYwMWJjMWEzNDdlMjkyZjI2ZDc0ODQ2ZTRhNWZiNTFlMzIwNjg5NDM2
11
+ YWZmZDg0OGQ3NmJjYTFkNzA3MWE1NzYzNDA0ODdlYjNjNzFmNzc=
12
12
  data.tar.gz: !binary |-
13
- Y2NiZjliN2Q1NDI1NmMwYWJiMmJmNTA3YTc1Mjc3M2MwNDgyMzc3NGIwMjk4
14
- MDNkY2ExNzkyMTVhZWUxOTAwNGEwMjZhZTQxMjlkMWMyYzYxY2M0NTQ3ODQ5
15
- Yzg5YjM1OTEyNjEzM2U2MmVmMzBmNmNjY2NmYWY5OTJlOWNjMjI=
13
+ NTE1OTYwYmYxYjlkYTVmMTk4NzRhNTFhMmIyNTM5MTQ1MjgwYTBlY2FlN2Ew
14
+ ZDJmZGI0NGI5MzA0Yzc0NzhiNTlkMDk0ZGM1NjZjOThmZmUxMDA0NDU4NTFj
15
+ YjVlOGZlMWQ5MDAzNzNiYTg0NWRmZTA1MDBhZTkzZDI4YWI2OWI=
data/.gitignore CHANGED
@@ -1,7 +1,5 @@
1
1
  *.gem
2
2
  .bundle/
3
3
  coverage/
4
- doc/
5
- .yardoc/
6
4
  measurements/
7
5
  Gemfile.lock
@@ -13,4 +13,4 @@ matrix:
13
13
  - rvm: ruby-head
14
14
  - rvm: jruby-head
15
15
  fast_finish: true
16
- script: "bundle exec rake -t ci:metrics spec:integration && (bundle exec rake -t metrics:mutant || true)"
16
+ script: "for i in examples/*.rb; do bundle exec ruby $i; done && bundle exec rake -t ci:metrics spec:integration && (bundle exec rake -t metrics:mutant || true)"
data/Gemfile CHANGED
@@ -13,5 +13,7 @@ platform :rbx do
13
13
  gem 'rubinius', '~> 2.0'
14
14
  end
15
15
 
16
+ gem 'rocco', git: 'https://github.com/rtomayko/rocco.git'
17
+
16
18
  # Added by devtools
17
19
  eval_gemfile 'Gemfile.devtools'
data/README.md CHANGED
@@ -1,24 +1,24 @@
1
- # The HTTP toolkit for Ruby
1
+ # The HTTP toolkit for Ruby
2
2
 
3
- HTTPkit is a Ruby toolkit for building HTTP clients and servers,
4
- as well as compositions of them.
3
+ HTTPkit is a Ruby toolkit for working with HTTP clients and servers.
5
4
 
6
- [![Build Status](https://travis-ci.org/lgierth/httpkit.png?branch=master)](https://travis-ci.org/lgierth/httpkit) [![Code Climate](https://codeclimate.com/github/lgierth/httpkit.png)](https://codeclimate.com/github/lgierth/httpkit) [![Coverage Status](https://coveralls.io/repos/lgierth/httpkit/badge.png?branch=master)](https://coveralls.io/r/lgierth/httpkit?branch=master)
5
+ [![Build Status](https://travis-ci.org/lgierth/httpkit.png?branch=master)](https://travis-ci.org/lgierth/httpkit)
7
6
 
8
- - \#1 feature: readable, high-quality, extendable code with 71.88% mutation coverage (wip)
9
- - \#2 feature: sophisticated request and response streaming
10
- - \#3 feature: compatible with Rack, Faraday, Webmachine for Ruby, and VCR (all todo)
11
- - \#4 feature: backed by Celluloid (wip) or Eventmachine
7
+ HTTPkit offers:
12
8
 
13
- *Note:* The `master` branch contains the in-progress rewrite towards
14
- HTTPkit 1.0. Look at the `0.5.x` branch for stable, but outdated and largely
15
- unmaintained releases. HTTPkit used to be called Hatetepe.
9
+ - extendable, high-quality code with consistent APIs, and 57.68% mutation coverage (wip)
10
+ - sophisticated request and response streaming
11
+ - integration with Webmachine for Ruby, and Rack (wip)
12
+ - compatibility with MRuby (todo), in addition to the usual: MRI, Rubinius, JRuby (todo)
13
+ - free and unencumbered public domain software
14
+
15
+ Before v0.6.0, HTTPkit was called Hatetepe and then underwent a ground-up rewrite. Look at the [0.5.x branch](https://github.com/lgierth/httpkit/tree/0.5.x) for the old code.
16
16
 
17
17
  ## Installation
18
18
 
19
19
  Add this line to your application's Gemfile:
20
20
 
21
- gem 'httpkit', '0.6.0.pre.3'
21
+ gem 'httpkit'
22
22
 
23
23
  And then execute:
24
24
 
@@ -26,24 +26,31 @@ And then execute:
26
26
 
27
27
  Or install it yourself as:
28
28
 
29
- $ gem install httpkit --pre
29
+ $ gem install httpkit
30
30
 
31
31
  ## Usage
32
32
 
33
- Code examples
34
-
35
- - [Getting started ](http://rubydoc.info/github/lgierth/httpkit/master/file/examples/getting_started.rb)
36
- - [HTTP echo server](http://rubydoc.info/github/lgierth/httpkit/master/file/examples/echo_server.rb)
33
+ The documentation is in a sorry state at the moment. The code examples are executable, though, and can be found in `examples/`.
37
34
 
38
- API Reference
35
+ Code examples
39
36
 
40
- - [HTTPkit::Client ](http://rubydoc.info/github/lgierth/httpkit/master/HTTPkit/Client)
41
- - [HTTPkit::Server ](http://rubydoc.info/github/lgierth/httpkit/master/HTTPkit/Server)
42
- - [HTTPkit::Response ](http://rubydoc.info/github/lgierth/httpkit/master/HTTPkit/Request)
43
- - [HTTPkit::Request ](http://rubydoc.info/github/lgierth/httpkit/master/HTTPkit/Response)
44
- - [HTTPkit::Body ](http://rubydoc.info/github/lgierth/httpkit/master/HTTPkit/Body)
45
- - [HTTPkit::Promise ](http://rubydoc.info/github/lgierth/httpkit/master/HTTPkit/Promise)
46
- - [HTTPkit::Serializer](http://rubydoc.info/github/lgierth/httpkit/master/HTTPkit/Serializer)
37
+ - [Getting started](http://httpkit.openposting.net/examples/getting_started.html)
38
+ - [HTTP echo server](http://httpkit.openposting.net/examples/echo_server.html)
39
+ - [Streaming](http://httpkit.openposting.net/examples/streaming.html)
40
+ - [Error handling](http://httpkit.openposting.net/examples/error_handling.html)
41
+ - [Connection status](http://httpkit.openposting.net/examples/connection_status.html)
42
+ - [Custom handlers](http://httpkit.openposting.net/examples/handlers.html)
43
+
44
+ API reference
45
+
46
+ - [HTTPkit](http://httpkit.openposting.net/api/httpkit.html)
47
+ - [HTTPkit::Client](http://httpkit.openposting.net/api/httpkit/client.html)
48
+ - [HTTPkit::Server](http://httpkit.openposting.net/api/httpkit/server.html)
49
+ - [HTTPkit::Request](http://httpkit.openposting.net/api/httpkit/request.html)
50
+ - [HTTPkit::Response](http://httpkit.openposting.net/api/httpkit/response.html)
51
+ - [HTTPkit::Body](http://httpkit.openposting.net/api/httpkit/body.html)
52
+ - [HTTPkit::Serializer](http://httpkit.openposting.net/api/httpkit/serializer.html)
53
+ - [HTTPkit::Promise](http://httpkit.openposting.net/api/httpkit/promise.html)
47
54
 
48
55
  ## To do
49
56
 
data/Rakefile CHANGED
@@ -1,5 +1,10 @@
1
1
  task :default => :spec
2
2
 
3
+ task :docs do
4
+ sh("cd lib/ ; bundle exec rocco -o ../doc/api/ $(find . -name '*.rb') ; cd ..")
5
+ sh('bundle exec rocco -o doc/ examples/*.rb')
6
+ end
7
+
3
8
  # Added by devtools
4
9
  require 'devtools'
5
10
  Devtools.init_rake_tasks
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 10
3
- total_score: 279
3
+ total_score: 287
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>httpkit.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="httpkit/body.html">body.rb</a>
17
+ <a class="source" href="httpkit/client.html">client.rb</a>
18
+ <a class="source" href="httpkit/client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="httpkit/client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="httpkit/client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="httpkit/client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="httpkit/connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="httpkit/connection/status.html">status.rb</a>
24
+ <a class="source" href="httpkit/promise.html">promise.rb</a>
25
+ <a class="source" href="httpkit/request.html">request.rb</a>
26
+ <a class="source" href="httpkit/response.html">response.rb</a>
27
+ <a class="source" href="httpkit/serializer.html">serializer.rb</a>
28
+ <a class="source" href="httpkit/server.html">server.rb</a>
29
+ <a class="source" href="httpkit/server/block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="httpkit/server/body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="httpkit/server/keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="httpkit/server/mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="httpkit/server/timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="httpkit/support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="httpkit/support/message.html">message.rb</a>
36
+ <a class="source" href="httpkit/version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>httpkit.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ </table>
49
+ </div>
50
+ </body>
@@ -0,0 +1,149 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>body.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="body.html">body.rb</a>
17
+ <a class="source" href="client.html">client.rb</a>
18
+ <a class="source" href="client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="connection/status.html">status.rb</a>
24
+ <a class="source" href="promise.html">promise.rb</a>
25
+ <a class="source" href="request.html">request.rb</a>
26
+ <a class="source" href="response.html">response.rb</a>
27
+ <a class="source" href="serializer.html">serializer.rb</a>
28
+ <a class="source" href="server.html">server.rb</a>
29
+ <a class="source" href="server/block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="server/body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="server/keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="server/mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="server/timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="support/message.html">message.rb</a>
36
+ <a class="source" href="version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>body.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <tr id='section-1'>
49
+ <td class=docs>
50
+ <div class="pilwrap">
51
+ <a class="pilcrow" href="#section-1">&#182;</a>
52
+ </div>
53
+
54
+ </td>
55
+ <td class=code>
56
+ <div class='highlight'><pre><span class="k">module</span> <span class="nn">HTTPkit</span>
57
+ <span class="k">class</span> <span class="nc">Body</span>
58
+ <span class="kp">include</span> <span class="ss">Adamantium</span><span class="p">:</span><span class="ss">:Mutable</span>
59
+
60
+ <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">build</span><span class="p">(</span><span class="n">source</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">,</span> <span class="n">length</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">)</span>
61
+ <span class="k">if</span> <span class="n">source</span><span class="o">.</span><span class="n">is_a?</span><span class="p">(</span><span class="nb">self</span><span class="p">)</span>
62
+ <span class="n">source</span>
63
+ <span class="k">else</span>
64
+ <span class="kp">new</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">length</span><span class="p">)</span>
65
+ <span class="k">end</span>
66
+ <span class="k">end</span>
67
+
68
+ <span class="kp">attr_reader</span> <span class="ss">:closed</span></pre></div>
69
+ </td>
70
+ </tr>
71
+ <tr id='section-2'>
72
+ <td class=docs>
73
+ <div class="pilwrap">
74
+ <a class="pilcrow" href="#section-2">&#182;</a>
75
+ </div>
76
+ <p>@param [String,#each,nil] source</p>
77
+
78
+ </td>
79
+ <td class=code>
80
+ <div class='highlight'><pre> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">source</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">,</span> <span class="n">length</span> <span class="o">=</span> <span class="kp">nil</span><span class="p">,</span> <span class="n">closed</span> <span class="o">=</span> <span class="no">Promise</span><span class="o">.</span><span class="n">new</span><span class="p">)</span>
81
+ <span class="vi">@source</span><span class="p">,</span> <span class="vi">@length</span> <span class="o">=</span> <span class="n">source</span><span class="p">,</span> <span class="n">length</span>
82
+ <span class="vi">@closed</span> <span class="o">=</span> <span class="n">closed</span>
83
+ <span class="vi">@chunks</span> <span class="o">=</span> <span class="o">[]</span>
84
+
85
+ <span class="n">apply_source</span>
86
+ <span class="vi">@closed</span><span class="o">.</span><span class="n">fulfill</span> <span class="k">if</span> <span class="n">source</span>
87
+ <span class="k">end</span>
88
+
89
+ <span class="k">def</span> <span class="nf">length</span>
90
+ <span class="vi">@length</span> <span class="o">||</span> <span class="mi">0</span>
91
+ <span class="k">end</span>
92
+
93
+ <span class="k">def</span> <span class="nf">length_known?</span>
94
+ <span class="o">!</span><span class="vi">@length</span><span class="o">.</span><span class="n">nil?</span>
95
+ <span class="k">end</span>
96
+
97
+ <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span>
98
+ <span class="k">if</span> <span class="vi">@closed</span><span class="o">.</span><span class="n">pending?</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="n">chunk</span><span class="o">.</span><span class="n">empty?</span>
99
+ <span class="vi">@chunks</span> <span class="o">&lt;&lt;</span> <span class="n">chunk</span>
100
+ <span class="vi">@closed</span><span class="o">.</span><span class="n">progress</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span>
101
+ <span class="k">end</span>
102
+ <span class="k">end</span>
103
+
104
+ <span class="k">def</span> <span class="nf">each</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
105
+ <span class="k">return</span> <span class="n">to_enum</span><span class="p">(</span><span class="n">__method__</span><span class="p">)</span> <span class="k">unless</span> <span class="n">block</span>
106
+
107
+ <span class="k">if</span> <span class="vi">@source</span><span class="o">.</span><span class="n">respond_to?</span><span class="p">(</span><span class="ss">:each</span><span class="p">)</span>
108
+ <span class="vi">@source</span><span class="o">.</span><span class="n">each</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
109
+ <span class="k">else</span>
110
+ <span class="n">each_chunk</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
111
+ <span class="k">end</span>
112
+ <span class="k">end</span>
113
+
114
+ <span class="k">def</span> <span class="nf">to_s</span>
115
+ <span class="n">each</span><span class="o">.</span><span class="n">to_a</span><span class="o">.</span><span class="n">join</span>
116
+ <span class="k">end</span>
117
+
118
+ <span class="k">def</span> <span class="nf">chunks</span>
119
+ <span class="vi">@chunks</span><span class="o">.</span><span class="n">dup</span>
120
+ <span class="k">end</span>
121
+
122
+ <span class="k">def</span> <span class="nf">inspect</span>
123
+ <span class="n">len</span> <span class="o">=</span> <span class="n">length_known?</span> <span class="p">?</span> <span class="n">length</span> <span class="p">:</span> <span class="s1">&#39;unknown&#39;</span>
124
+ <span class="nb">sprintf</span><span class="p">(</span><span class="s1">&#39;#&lt;%s:0x%d @length=%s&gt;&#39;</span><span class="p">,</span> <span class="nb">self</span><span class="o">.</span><span class="n">class</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">object_id</span><span class="p">,</span> <span class="n">len</span><span class="p">)</span>
125
+ <span class="k">end</span>
126
+
127
+ <span class="kp">private</span>
128
+
129
+ <span class="k">def</span> <span class="nf">apply_source</span>
130
+ <span class="k">if</span> <span class="vi">@source</span><span class="o">.</span><span class="n">respond_to?</span><span class="p">(</span><span class="ss">:to_str</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="n">chunk</span> <span class="o">=</span> <span class="vi">@source</span><span class="o">.</span><span class="n">to_str</span><span class="p">)</span>
131
+ <span class="vi">@length</span> <span class="o">=</span> <span class="n">chunk</span><span class="o">.</span><span class="n">bytesize</span>
132
+ <span class="n">write</span><span class="p">(</span><span class="n">chunk</span><span class="p">)</span>
133
+ <span class="k">elsif</span> <span class="vi">@source</span><span class="o">.</span><span class="n">respond_to?</span><span class="p">(</span><span class="ss">:bytesize</span><span class="p">)</span>
134
+ <span class="vi">@length</span> <span class="o">=</span> <span class="vi">@source</span><span class="o">.</span><span class="n">bytesize</span>
135
+ <span class="k">end</span>
136
+ <span class="k">end</span>
137
+
138
+ <span class="k">def</span> <span class="nf">each_chunk</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
139
+ <span class="vi">@closed</span><span class="o">.</span><span class="n">on_progress</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
140
+ <span class="vi">@chunks</span><span class="o">.</span><span class="n">dup</span><span class="o">.</span><span class="n">each</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
141
+ <span class="vi">@closed</span><span class="o">.</span><span class="n">sync</span>
142
+ <span class="k">end</span>
143
+ <span class="k">end</span>
144
+ <span class="k">end</span></pre></div>
145
+ </td>
146
+ </tr>
147
+ </table>
148
+ </div>
149
+ </body>
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>client.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="body.html">body.rb</a>
17
+ <a class="source" href="client.html">client.rb</a>
18
+ <a class="source" href="client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="connection/status.html">status.rb</a>
24
+ <a class="source" href="promise.html">promise.rb</a>
25
+ <a class="source" href="request.html">request.rb</a>
26
+ <a class="source" href="response.html">response.rb</a>
27
+ <a class="source" href="serializer.html">serializer.rb</a>
28
+ <a class="source" href="server.html">server.rb</a>
29
+ <a class="source" href="server/block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="server/body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="server/keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="server/mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="server/timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="support/message.html">message.rb</a>
36
+ <a class="source" href="version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>client.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ </table>
49
+ </div>
50
+ </body>
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>body_handler.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="../body.html">body.rb</a>
17
+ <a class="source" href="../client.html">client.rb</a>
18
+ <a class="source" href="body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="../connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="../connection/status.html">status.rb</a>
24
+ <a class="source" href="../promise.html">promise.rb</a>
25
+ <a class="source" href="../request.html">request.rb</a>
26
+ <a class="source" href="../response.html">response.rb</a>
27
+ <a class="source" href="../serializer.html">serializer.rb</a>
28
+ <a class="source" href="../server.html">server.rb</a>
29
+ <a class="source" href="../server/block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="../server/body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="../server/keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="../server/mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="../server/timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="../support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="../support/message.html">message.rb</a>
36
+ <a class="source" href="../version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>body_handler.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ </table>
49
+ </div>
50
+ </body>