incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <d...@apache.org>
Subject [PATCH] Fix for DTACLOUD-18 : Missing Host header not handled
Date Sun, 25 Sep 2011 21:21:15 GMT
---
 server/lib/sinatra/sinatra_verbose.rb |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/server/lib/sinatra/sinatra_verbose.rb b/server/lib/sinatra/sinatra_verbose.rb
index c016ec0..043463a 100644
--- a/server/lib/sinatra/sinatra_verbose.rb
+++ b/server/lib/sinatra/sinatra_verbose.rb
@@ -39,6 +39,13 @@ module Sinatra
 
     end
 
+    def check_host_header
+      disable :logging
+      before {
+        halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
+      }
+    end
+
     def enable_verbose_logging!
       disable :logging
       before {
@@ -62,6 +69,7 @@ module Sinatra
     def self.registered(app)
       app.helpers VerboseLogger::Helpers
       app.enable_verbose_logging! if ENV['API_VERBOSE']
+      app.check_host_header
     end
   end
 end
-- 
1.7.1


Mime
View raw message