clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: clogger@librelist.org
Subject: [PATCH] tests: add full URL example
Date: Wed, 11 May 2011 19:24:05 -0700	[thread overview]
Message-ID: <20110512022405.GA32249@dcvr.yhbt.net> (raw)
In-Reply-To: <20110512022405.GA32249@dcvr.yhbt.net>

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 <normalperson@yhbt.net>
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


           reply	other threads:[~2011-05-12  2:24 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20110512022405.GA32249@dcvr.yhbt.net>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/clogger/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110512022405.GA32249@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=clogger@librelist.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/clogger.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).