diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-11-09 19:09:06 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-11-09 19:09:06 +0900 |
commit | 3b460e375507e5393994b3e82a19253d5d0bcddd (patch) | |
tree | a45b9dcb3e09256511c4c473994c8173b6811d9d | |
parent | 11be104f7ac9e2fe91bd5f82a1bb2489692cdce8 (diff) | |
download | plum-3b460e375507e5393994b3e82a19253d5d0bcddd.tar.gz |
examples: fix client examples
-rw-r--r-- | examples/client/large.rb | 6 | ||||
-rw-r--r-- | examples/client/twitter.rb | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/examples/client/large.rb b/examples/client/large.rb index 5cedf91..3db0df3 100644 --- a/examples/client/large.rb +++ b/examples/client/large.rb @@ -1,6 +1,6 @@ # -*- frozen-string-literal: true -*- # client/large.rb: download 3 large files in parallel -$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) +$LOAD_PATH.unshift File.expand_path("../../../lib", __FILE__) require "plum" def log(s) @@ -9,8 +9,8 @@ end Plum::Client.start("http2.golang.org", 443, http2_settings: { max_frame_size: 32768 }) { |rest| 3.times { |i| - rest.get_async("/file/go.src.tar.gz", - headers: { "accept-encoding" => "identity;q=1" }) { |res| + rest.get("/file/go.src.tar.gz", + headers: { "accept-encoding" => "identity;q=1" }) { |res| log "#{i}: #{res.status}" res.on_chunk { |chunk| log "#{i}: chunk: #{chunk.size}" diff --git a/examples/client/twitter.rb b/examples/client/twitter.rb index d5796d8..69d2224 100644 --- a/examples/client/twitter.rb +++ b/examples/client/twitter.rb @@ -2,7 +2,7 @@ # client/twitter.rb # Twitter の User stream に(現在はサーバーが非対応のため)HTTP/1.1 を使用して接続する。 # 「にゃーん」を含むツイートを受信したら、REST API で HTTP/2 を使用して返信する。 -$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) +$LOAD_PATH.unshift File.expand_path("../../../lib", __FILE__) require "plum" require "json" require "cgi" @@ -39,10 +39,10 @@ Plum::Client.start("userstream.twitter.com", 443) { |streaming| if /にゃーん/ =~ json["text"] args = { "status" => "@#{json["user"]["screen_name"]} にゃーん", "in_reply_to_status_id" => json["id"].to_s } - rest.post("/1.1/statuses/update.json", - args.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&"), - headers: { "authorization" => SimpleOAuth::Header.new(:post, "https://api.twitter.com/1.1/statuses/update.json", args, credentials).to_s, - "content-type" => "application/x-www-form-urlencoded" }) + rest.post!("/1.1/statuses/update.json", + args.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&"), + headers: { "authorization" => SimpleOAuth::Header.new(:post, "https://api.twitter.com/1.1/statuses/update.json", args, credentials).to_s, + "content-type" => "application/x-www-form-urlencoded" }) end end } |