clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / Atom feed
* [PATCH] tests: add full URL example
@ 2011-05-12  2:24 Eric Wong
  0 siblings, 0 replies; 1+ messages in thread
From: Eric Wong @ 2011-05-12  2:24 UTC (permalink / raw)
  To: clogger

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


^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12  2:24 [PATCH] tests: add full URL example Eric Wong

clogger RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/clogger-public
	git clone --mirror http://ou63pmih66umazou.onion/clogger-public

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.clogger
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.clogger

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox