File tree 4 files changed +63
-0
lines changed
4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ invoker_profile/
14
14
.ruby-version
15
15
Gemfile.lock
16
16
.overcommit.yml
17
+ Procfile
Original file line number Diff line number Diff line change @@ -64,6 +64,11 @@ def headers_received(headers)
64
64
return
65
65
end
66
66
@session = UUID . generate ( )
67
+ if !headers [ 'Host' ] || headers [ 'Host' ] . empty?
68
+ return_error_page ( 400 )
69
+ return
70
+ end
71
+
67
72
dns_check_response = UrlRewriter . new . select_backend_config ( headers [ 'Host' ] )
68
73
if dns_check_response && dns_check_response . port
69
74
connection . server ( session , host : '0.0.0.0' , port : dns_check_response . port )
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < title > Invoker</ title >
6
+ < style >
7
+ body {
8
+ margin : 0 ;
9
+ padding : 0 ;
10
+ background : # fff ;
11
+ line-height : 18px ;
12
+ }
13
+ div .page {
14
+ padding : 36px 90px ;
15
+ }
16
+ h1 , h2 , p , li {
17
+ font-family : Helvetica, sans-serif;
18
+ font-size : 13px ;
19
+ }
20
+ h1 {
21
+ line-height : 45px ;
22
+ font-size : 36px ;
23
+ margin : 0 ;
24
+ }
25
+ h2 {
26
+ line-height : 27px ;
27
+ font-size : 18px ;
28
+ font-weight : normal;
29
+ margin : 0 ;
30
+ }
31
+ </ style >
32
+ </ head >
33
+ < body class ="">
34
+ < div class ="page ">
35
+ < h1 > Bad request</ h1 >
36
+ < hr >
37
+ < h2 > Invoker couldn't understand the request</ h2 >
38
+ </ div >
39
+ </ body >
40
+ </ html >
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
3
3
describe Invoker ::Power ::Balancer do
4
+ before do
5
+ @http_connection = mock ( "connection" )
6
+ @balancer = Invoker ::Power ::Balancer . new ( @http_connection , "http" )
7
+ end
4
8
9
+ context "when Host field is missing in the request" do
10
+ it "should return 400 as response when Host is missing" do
11
+ headers = { }
12
+ @http_connection . expects ( :send_data ) . with ( ) { |value | value =~ /400 Bad Request/i }
13
+ @balancer . headers_received ( headers )
14
+ end
15
+
16
+ it "should return 400 as response when Host is empty" do
17
+ headers = { 'Host' => '' }
18
+ @http_connection . expects ( :send_data ) . with ( ) { |value | value =~ /400 Bad Request/i }
19
+ @balancer . headers_received ( headers )
20
+ end
21
+ end
5
22
end
You can’t perform that action at this time.
0 commit comments