From b097be288dd6006cfbc93783dc429fc09341f2c0 Mon Sep 17 00:00:00 2001 From: Corey Donohoe Date: Sat, 4 Dec 2010 16:40:04 -0800 Subject: [PATCH 1/3] allow for disabling logging --- server.coffee | 18 ++++++++++-------- test/proxy_test.rb | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/server.coffee b/server.coffee index 5dfe0c9..2c07f27 100644 --- a/server.coffee +++ b/server.coffee @@ -4,14 +4,16 @@ Http = require 'http' Crypto = require 'crypto' QueryString = require 'querystring' -port = parseInt process.env.PORT || 8081 -version = "0.2.2" -shared_key = process.env.CAMO_KEY || '0x24FEEDFACEDEADBEEFCAFE' +port = parseInt process.env.PORT || 8081 +version = "0.3.0" +shared_key = process.env.CAMO_KEY || '0x24FEEDFACEDEADBEEFCAFE' +logging_enabled = process.env.CAMO_LOGGING_ENABLED || "disabled" log = (msg) -> - console.log("--------------------------------------------") - console.log(msg) - console.log("--------------------------------------------") + unless logging_enabled == "disabled" + console.log("--------------------------------------------") + console.log(msg) + console.log("--------------------------------------------") server = Http.createServer (req, resp) -> if req.method != 'GET' || req.url == '/' @@ -102,7 +104,7 @@ server = Http.createServer (req, resp) -> resp.writeHead srcResp.statusCode, newHeaders else - four_oh_four("Responded with #{srcResp.statusCode}") + four_oh_four("Responded with #{srcResp.statusCode}:#{srcResp.headers}") srcReq.on 'error', -> resp.end() @@ -112,7 +114,7 @@ server = Http.createServer (req, resp) -> else four_oh_four("No host found") else - four_oh_four("checksum mismatch") + four_oh_four("checksum mismatch #{hmac_digest}:#{query_digest}") else four_oh_four("No pathname provided on the server") diff --git a/test/proxy_test.rb b/test/proxy_test.rb index a09aa48..452f84d 100644 --- a/test/proxy_test.rb +++ b/test/proxy_test.rb @@ -7,10 +7,10 @@ require 'test/unit' -class AssetProxyTest < Test::Unit::TestCase +class CamoProxyTest < Test::Unit::TestCase def config - { 'key' => "0x24FEEDFACEDEADBEEFCAFE", - 'host' => "http://localhost:8081" } + { 'key' => ENV['CAMO_KEY'] || "0x24FEEDFACEDEADBEEFCAFE", + 'host' => ENV['CAMO_HOST'] || "http://localhost:8081" } end def request(image_url) From bf1c26ce368c6ff1fee2c544eac9e0d1b9e33c05 Mon Sep 17 00:00:00 2001 From: Corey Donohoe Date: Sat, 4 Dec 2010 18:48:10 -0800 Subject: [PATCH 2/3] support tasks so deployment/checking is easier --- Rakefile | 5 +++++ tasks/.gitignore | 0 2 files changed, 5 insertions(+) create mode 100644 tasks/.gitignore diff --git a/Rakefile b/Rakefile index 44c4112..f236fee 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,11 @@ namespace :test do + desc "Run the tests against localhost" task :check do |t| system("ruby test/proxy_test.rb") end end task :default => "test:check" + +Dir["tasks/*.rake"].each do |f| + load f +end diff --git a/tasks/.gitignore b/tasks/.gitignore new file mode 100644 index 0000000..e69de29 From c8761eb365666b4ddc27478dd556e3b931578842 Mon Sep 17 00:00:00 2001 From: Corey Donohoe Date: Sat, 4 Dec 2010 19:10:34 -0800 Subject: [PATCH 3/3] allo server.js for tags --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8ed7196..8c76aa0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ tmp/camouflage.pid -server.js tmp/camo.pid