You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Davanum Srinivas <di...@apache.org> on 2011/09/25 23:21:15 UTC
[PATCH] Fix for DTACLOUD-18 : Missing Host header not handled
---
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
Re: [PATCH] [PATCH] Fix for DTACLOUD-18 : Missing Host header not
handled
Posted by David Lutterkort <lu...@redhat.com>.
ACK. Committed. Since I committed your other patch first, had to do this
by hand, too. Sorry about the confusion.
David
On Mon, 2011-09-26 at 09:38 -0400, Davanum Srinivas wrote:
> ---
> server/server.rb | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/server/server.rb b/server/server.rb
> index 072e888..9d9035c 100644
> --- a/server/server.rb
> +++ b/server/server.rb
> @@ -77,6 +77,11 @@ error do
> report_error
> end
>
> +before do
> + # Respond with 400, If we don't get a http Host header,
> + halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
> +end
> +
> # Redirect to /api
> get '/' do redirect root_url, 301; end
>
[PATCH] [PATCH] Fix for DTACLOUD-18 : Missing Host header not handled
Posted by Davanum Srinivas <di...@apache.org>.
---
server/server.rb | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/server/server.rb b/server/server.rb
index 072e888..9d9035c 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -77,6 +77,11 @@ error do
report_error
end
+before do
+ # Respond with 400, If we don't get a http Host header,
+ halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
+end
+
# Redirect to /api
get '/' do redirect root_url, 301; end
--
1.7.1
Re: [PATCH] Fix for DTACLOUD-18 : Missing Host header not handled
Posted by Davanum Srinivas <da...@gmail.com>.
Sent. yes, i have a ICLA on file - http://people.apache.org/committer-index.html
On Mon, Sep 26, 2011 at 9:34 AM, Michal Fojtik <mi...@mifo.sk> wrote:
> On Sep 26, 2011, at 2:56 PM, dims@apache.org wrote:
>
>> +before do
>> + # Respond with 400, If we don't get a http Host header,
>> + halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
>> +end
>> +
>> # Redirect to /api
>> get '/' do redirect root_url, 301; end
>>
>
> ACK. Could you please send it in proper git format, so I can push it with your
> signature?
>
> PS: I assume you have signed Apache CLA.
>
> -- Michal
--
Davanum Srinivas :: http://davanum.wordpress.com
Re: [PATCH] Fix for DTACLOUD-18 : Missing Host header not handled
Posted by Michal Fojtik <mi...@mifo.sk>.
On Sep 26, 2011, at 2:56 PM, dims@apache.org wrote:
> +before do
> + # Respond with 400, If we don't get a http Host header,
> + halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
> +end
> +
> # Redirect to /api
> get '/' do redirect root_url, 301; end
>
ACK. Could you please send it in proper git format, so I can push it with your
signature?
PS: I assume you have signed Apache CLA.
-- Michal
Re: [PATCH] Fix for DTACLOUD-18 : Missing Host header not handled
Posted by di...@apache.org.
+before do
+ # Respond with 400, If we don't get a http Host header,
+ halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
+end
+
# Redirect to /api
get '/' do redirect root_url, 301; end
Re: [PATCH] Fix for DTACLOUD-18 : Missing Host header not handled
Posted by Michal Fojtik <mf...@redhat.com>.
On Sep 25, 2011, at 11:21 PM, Davanum Srinivas wrote:
Nice catch Davanum! ACK.
Btw. I think this method should go to a separate Rack middleware file,
like (server/lib/sinatra/sinatra_check_host.rb) or to server.rb directly.
The sinatra_verbose module is designed to do just 'logging' and debugging
stuff.
-- Michal
> ---
> 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
>
------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org