From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6939 64.71.128.0/18 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.clogger.general Subject: [PATCH] tests: add full URL example Date: Wed, 11 May 2011 19:24:05 -0700 Message-ID: <20110512022405.GA32249@dcvr.yhbt.net> References: <20110512022405.GA32249@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1305167066 23259 80.91.229.12 (12 May 2011 02:24:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 12 May 2011 02:24:26 +0000 (UTC) To: clogger@librelist.org Original-X-From: clogger@librelist.org Thu May 12 04:24:21 2011 Return-path: Envelope-to: gcrcg-clogger@m.gmane.org In-Reply-To: <20110512022405.GA32249@dcvr.yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: clogger@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.clogger.general:51 Archived-At: Received: from zedshaw.xen.prgmr.com ([64.71.167.205]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QKLZc-0008TG-Sk for gcrcg-clogger@m.gmane.org; Thu, 12 May 2011 04:24:21 +0200 Received: from zedshaw.xen.prgmr.com (localhost [IPv6:::1]) by zedshaw.xen.prgmr.com (Postfix) with ESMTP id B062521C970 for ; Thu, 12 May 2011 02:25:34 +0000 (UTC) In case anyone is interested in getting the full URL with hostname, here's how I did it: >>From 5979a9b113815721140058d021ecfffc5c529de4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 11 May 2011 18:54:47 -0700 Subject: [PATCH] tests: add full URL example Could be useful for some folks. --- test/test_clogger.rb | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/test/test_clogger.rb b/test/test_clogger.rb index 9440d74..35a211a 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -28,6 +28,7 @@ class TestClogger < Test::Unit::TestCase "QUERY_STRING" => "goodbye=true", "rack.errors" => $stderr, "rack.input" => File.open('/dev/null', 'rb'), + "rack.url_scheme" => "http", "REMOTE_ADDR" => 'home', } end @@ -795,4 +796,16 @@ class TestClogger < Test::Unit::TestCase assert_equal :PONIES, s[1] assert_equal 2, s.size end + + def test_full_uri + s = [] + format = '"$request_method ' \ + '$env{rack.url_scheme}://$http_host$request_uri $http_version"' + app = lambda { |env| [200, [], [] ] } + cl = Clogger.new(app, :logger => s, :format => format) + @req["HTTP_HOST"] = "example.com" + status, headers, body = cl.call(@req) + expect = "\"GET http://example.com/hello?goodbye=true HTTP/1.0\"\n" + assert_equal [ expect ], s + end end -- Eric Wong