File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 5252 }
5353 end
5454
55+ it "should strip basic auth from before the host in URI sent to proxy" do
56+ EventMachine . run {
57+
58+ http = EventMachine ::HttpRequest . new ( 'http://user:pass@127.0.0.1:8090/echo_authorization_header' , proxy ) . get
59+
60+ http . errback { failed ( http ) }
61+ http . callback {
62+ http . response_header . status . should == 200
63+ # The test proxy server gives the requested uri back in this header
64+ http . response_header [ 'X_THE_REQUESTED_URI' ] . should == 'http://127.0.0.1:8090/echo_authorization_header'
65+ # Ensure the basic auth was converted to a header correctly
66+ http . response . should match ( 'authorization:Basic dXNlcjpwYXNz' )
67+ EventMachine . stop
68+ }
69+ }
70+ end
71+
5572 it "should include query parameters specified in the options" do
5673 EventMachine . run {
5774 http = EventMachine ::HttpRequest . new ( 'http://127.0.0.1:8090/' , proxy ) . get :query => { 'q' => 'test' }
Original file line number Diff line number Diff line change @@ -96,6 +96,9 @@ def self.call(env)
9696 elsif stable . request . path_info == '/echo_content_length_from_header'
9797 stable . response . write "content-length:#{ stable . request . env [ "CONTENT_LENGTH" ] } "
9898
99+ elsif stable . request . path_info == '/echo_authorization_header'
100+ stable . response . write "authorization:#{ stable . request . env [ "HTTP_AUTHORIZATION" ] } "
101+
99102 elsif stable . request . head? && stable . request . path_info == '/'
100103 stable . response . status = 200
101104
You can’t perform that action at this time.
0 commit comments