diff options
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | examples/client/twitter.rb | 10 |
2 files changed, 9 insertions, 7 deletions
@@ -71,10 +71,10 @@ If the server does't support HTTP/2, `Plum::Client` tries to use HTTP/1.x instea ##### Sequential request ```ruby -client = Plum::Client.start("http2.rhe.jp", 443, user_agent: "nyaan") -res1 = client.get!("/", headers: { "accept" => "*/*" }) +client = Plum::Client.start("http2.rhe.jp", user_agent: "nyaan") +res1 = client.get("/", headers: { "accept" => "*/*" }).join puts res1.body # => "..." -res2 = client.post!("/post", "data") +res2 = client.post("/post", "data").join puts res2.body # => "..." client.close diff --git a/examples/client/twitter.rb b/examples/client/twitter.rb index 88f742f..00d41c8 100644 --- a/examples/client/twitter.rb +++ b/examples/client/twitter.rb @@ -40,10 +40,12 @@ 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" } + ).join end end } |