@@ -56,32 +56,42 @@ class Elasticsearch::Transport::Transport::HTTP::ManticoreTest < Minitest::Test
5656
5757 should "set body for GET request" do
5858 @transport . connections . first . connection . expects ( :get ) .
59- with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' } ) . returns ( stub_everything )
59+ with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' ,
60+ :headers => { "Content-Type" => "application/json" ,
61+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
6062 @transport . perform_request 'GET' , '/' , { } , '{"foo":"bar"}'
6163 end
6264
6365 should "set body for PUT request" do
6466 @transport . connections . first . connection . expects ( :put ) .
65- with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' } ) . returns ( stub_everything )
67+ with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' ,
68+ :headers => { "Content-Type" => "application/json" ,
69+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
6670 @transport . perform_request 'PUT' , '/' , { } , { :foo => 'bar' }
6771 end
6872
6973 should "serialize the request body" do
7074 @transport . connections . first . connection . expects ( :post ) .
71- with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' } ) . returns ( stub_everything )
75+ with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' ,
76+ :headers => { "Content-Type" => "application/json" ,
77+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
7278 @transport . perform_request 'POST' , '/' , { } , { 'foo' => 'bar' }
7379 end
7480
7581 should "set custom headers for PUT request" do
7682 @transport . connections . first . connection . expects ( :put ) .
77- with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' , :headers => { "Content-Type" => "application/x-ndjson" } } )
83+ with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' ,
84+ :headers => { "Content-Type" => "application/json" ,
85+ "User-Agent" => @transport . send ( :user_agent_header ) } } )
7886 . returns ( stub_everything )
7987 @transport . perform_request 'PUT' , '/' , { } , '{"foo":"bar"}' , { "Content-Type" => "application/x-ndjson" }
8088 end
8189
8290 should "not serialize a String request body" do
8391 @transport . connections . first . connection . expects ( :post ) .
84- with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' } ) . returns ( stub_everything )
92+ with ( 'http://127.0.0.1:8080//' , { :body => '{"foo":"bar"}' ,
93+ :headers => { "Content-Type" => "application/json" ,
94+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
8595 @transport . serializer . expects ( :dump ) . never
8696 @transport . perform_request 'POST' , '/' , { } , '{"foo":"bar"}'
8797 end
@@ -93,7 +103,8 @@ class Elasticsearch::Transport::Transport::HTTP::ManticoreTest < Minitest::Test
93103
94104 transport = Manticore . new :hosts => [ { :host => 'localhost' , :port => 8080 } ] , :options => options
95105
96- transport . connections . first . connection . stub ( "http://localhost:8080//" , :body => "\" \" " , :headers => { "content-type" => "application/json" } , :code => 200 )
106+ transport . connections . first . connection . stub ( "http://localhost:8080//" , :body => "\" \" " , :headers => { "Content-Type" => "application/x-ndjson" ,
107+ "User-Agent" => @transport . send ( :user_agent_header ) } , :code => 200 )
97108
98109 response = transport . perform_request 'GET' , '/' , { }
99110 assert_equal response . status , 200
@@ -113,11 +124,16 @@ class Elasticsearch::Transport::Transport::HTTP::ManticoreTest < Minitest::Test
113124 end
114125
115126 should "handle HTTP methods" do
116- @transport . connections . first . connection . expects ( :delete ) . with ( 'http://127.0.0.1:8080//' , { } ) . returns ( stub_everything )
117- @transport . connections . first . connection . expects ( :head ) . with ( 'http://127.0.0.1:8080//' , { } ) . returns ( stub_everything )
118- @transport . connections . first . connection . expects ( :get ) . with ( 'http://127.0.0.1:8080//' , { } ) . returns ( stub_everything )
119- @transport . connections . first . connection . expects ( :put ) . with ( 'http://127.0.0.1:8080//' , { } ) . returns ( stub_everything )
120- @transport . connections . first . connection . expects ( :post ) . with ( 'http://127.0.0.1:8080//' , { } ) . returns ( stub_everything )
127+ @transport . connections . first . connection . expects ( :delete ) . with ( 'http://127.0.0.1:8080//' , { headers : { "Content-Type" => "application/json" ,
128+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
129+ @transport . connections . first . connection . expects ( :head ) . with ( 'http://127.0.0.1:8080//' , { headers : { "Content-Type" => "application/json" ,
130+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
131+ @transport . connections . first . connection . expects ( :get ) . with ( 'http://127.0.0.1:8080//' , { headers : { "Content-Type" => "application/json" ,
132+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
133+ @transport . connections . first . connection . expects ( :put ) . with ( 'http://127.0.0.1:8080//' , { headers : { "Content-Type" => "application/json" ,
134+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
135+ @transport . connections . first . connection . expects ( :post ) . with ( 'http://127.0.0.1:8080//' , { headers : { "Content-Type" => "application/json" ,
136+ "User-Agent" => @transport . send ( :user_agent_header ) } } ) . returns ( stub_everything )
121137
122138 %w| HEAD GET PUT POST DELETE | . each { |method | @transport . perform_request method , '/' }
123139
0 commit comments