diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-09 02:17:39 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-09 02:17:39 +0900 |
commit | 9190801a092d46c7079ccee201b212b2d7985952 (patch) | |
tree | bc08c828d7144d3553dfa759f558fe32d5d458e0 | |
parent | ef9daa152ecf2e3f9fe0f2c5eb083379a5077c3b (diff) | |
parent | 9e8ad7fe935e160a25dd21735dc23e9323c1146a (diff) | |
download | plum-master.tar.gz |
* topic/prepare-0.3:
readme: update for 0.3
bump up version to 0.3.0
-rw-r--r-- | README.md | 44 | ||||
-rw-r--r-- | lib/plum/version.rb | 2 |
2 files changed, 34 insertions, 12 deletions
@@ -1,4 +1,5 @@ # Plum: An HTTP/2 Library for Ruby + A pure Ruby HTTP/2 server and client implementation. WARNING: Plum is currently under heavy development. You *will* encounter bugs when using it. @@ -9,18 +10,24 @@ WARNING: Plum is currently under heavy development. You *will* encounter bugs wh ## Requirements * Ruby 2.3 -* OpenSSL 1.0.2 or newer (HTTP/2 requires ALPN) -* Optional: - * [http_parser.rb gem](https://rubygems.org/gems/http_parser.rb) (HTTP/1.x parser; if you use "http" URI scheme) - * [rack gem](https://rubygems.org/gems/rack) (if you use Plum as Rack server) +* OpenSSL 1.0.2 or newer +* [http_parser.rb gem](https://rubygems.org/gems/http_parser.rb) - if you need HTTP/2 without TLS or HTTP/1.1 support +* [rack gem](https://rubygems.org/gems/rack) - if you use plum as a Rack server ## Installation +You can install via rubygems: + ~~~sh gem install plum ~~~ +then require it: + +~~~ruby +require "plum" +~~~ ## Usage @@ -53,9 +60,12 @@ You can run it: NOTE: If `--cert` and `--key` are omitted, a temporary dummy certificate will be generated. +My website [https://rhe.jp](https://rhe.jp) is using plum as a Rack server. + ### As a HTTP/2 (HTTP/1.x) client library -If the server does't support HTTP/2, `Plum::Client` tries to use HTTP/1.x instead. + +If the server doesn't support HTTP/2, it falls back to HTTP/1.1 seamlessly. ~~~ +-----------------+ @@ -83,6 +93,14 @@ puts res1.body # => "..." res2 = client.post("/post", "data").join puts res2.body # => "..." +client.get("/clockstream").on_headers { |res| + puts "status: #{res.status}, headers: #{res.headers}" +}.on_chunk { |chunk| + puts chunk +}.on_finish { + puts "finish!" +}.join + client.close ~~~ @@ -104,6 +122,7 @@ p res1.status # => "200" ##### Download a large file ~~~ruby +# the value of hostname option will be used in SNI and :authority header Plum::Client.start("http2.rhe.jp", 443, hostname: "assets.rhe.jp") { |client| client.get("/large") do |res| # called when received response headers p res.status # => "200" @@ -119,12 +138,15 @@ Plum::Client.start("http2.rhe.jp", 443, hostname: "assets.rhe.jp") { |client| ## TODO -* **Better API** -* Plum::Client - * PING frame handling - * Server Push support - * Stream Priority support - * Better HTTP/1.x support +* Better API design +* Better server push support +* Stream priority support + +Of course ideas and pull requests are welcome. + +## Hacking + +Clone this Git repository and run `bundle install` to install development dependencies. You can run test with `rake test`. The tests are written with Minitest. ## License diff --git a/lib/plum/version.rb b/lib/plum/version.rb index 079ae47..1ba7997 100644 --- a/lib/plum/version.rb +++ b/lib/plum/version.rb @@ -1,5 +1,5 @@ # frozen-string-literal: true module Plum - VERSION = "0.2.10" + VERSION = "0.3.0" end |