* [PATCH] tests: add full URL example
@ 2011-05-12 2:24 14% Eric Wong
0 siblings, 0 replies; 1+ results
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 related [relevance 14%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2011-05-12 2:24 14% [PATCH] tests: add full URL example Eric Wong
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).