From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6B48E1F855 for ; Wed, 27 Jul 2016 22:51:55 +0000 (UTC) From: Eric Wong To: raindrops-public@bogomips.org Subject: [PATCH] drop Rack::Utils.bytesize dependency Date: Wed, 27 Jul 2016 22:51:55 +0000 Message-Id: <20160727225155.30453-1-e@80x24.org> List-Id: rack 2.0 removes this method, but we actually don't need it since any strings we generate are binary and Aggregate#to_s output is 7-bit clean. --- lib/raindrops/watcher.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/raindrops/watcher.rb b/lib/raindrops/watcher.rb index fb2df5b..f0abd1d 100644 --- a/lib/raindrops/watcher.rb +++ b/lib/raindrops/watcher.rb @@ -244,10 +244,10 @@ def agg_to_hash(reset_at, agg, current, peak) def histogram_txt(agg) updated_at, reset_at, agg, current, peak = *agg headers = agg_to_hash(reset_at, agg, current, peak) - body = agg.to_s + body = agg.to_s # 7-bit ASCII-clean headers["Content-Type"] = "text/plain" headers["Expires"] = (updated_at + @delay).httpdate - headers["Content-Length"] = bytesize(body).to_s + headers["Content-Length"] = body.size.to_s [ 200, headers, [ body ] ] end @@ -265,7 +265,7 @@ def histogram_html(agg, addr) "" headers["Content-Type"] = "text/html" headers["Expires"] = (updated_at + @delay).httpdate - headers["Content-Length"] = bytesize(body).to_s + headers["Content-Length"] = body.size.to_s [ 200, headers, [ body ] ] end @@ -364,7 +364,7 @@ def index "for more information and options." \ "

" \ "" - headers["Content-Length"] = bytesize(body).to_s + headers["Content-Length"] = body.size.to_s [ 200, headers, [ body ] ] end @@ -382,7 +382,7 @@ def initialize(rdmon, addr, env) # :nodoc: q = Rack::Utils.parse_query env["QUERY_STRING"] @active_min = q["active_min"].to_i @queued_min = q["queued_min"].to_i - len = Rack::Utils.bytesize(addr) + len = addr.size len = 35 if len > 35 @fmt = "%20s % #{len}s % 10u % 10u\n" case env["HTTP_VERSION"] -- EW