@@ -1848,6 +1848,23 @@ def string
18481848 assert_equal 200 , response [ 0 ]
18491849 end
18501850
1851+ test "POST request with empty members in the Accept header succeeds" do
1852+ [ "application/json,,text/event-stream" , ", application/json, text/event-stream" ] . each do |accept |
1853+ request = create_rack_request_without_accept (
1854+ "POST" ,
1855+ "/" ,
1856+ {
1857+ "CONTENT_TYPE" => "application/json" ,
1858+ "HTTP_ACCEPT" => accept ,
1859+ } ,
1860+ { jsonrpc : "2.0" , method : "initialize" , id : "123" , params : initialize_params } . to_json ,
1861+ )
1862+
1863+ response = @transport . handle_request ( request )
1864+ assert_equal 200 , response [ 0 ] , accept . inspect
1865+ end
1866+ end
1867+
18511868 test "POST request with Accept: */* succeeds" do
18521869 request = create_rack_request_without_accept (
18531870 "POST" ,
@@ -1978,6 +1995,30 @@ def string
19781995 assert_equal "text/event-stream" , response [ 1 ] [ "content-type" ]
19791996 end
19801997
1998+ test "GET request with an empty member in the Accept header succeeds" do
1999+ init_request = create_rack_request (
2000+ "POST" ,
2001+ "/" ,
2002+ { "CONTENT_TYPE" => "application/json" } ,
2003+ { jsonrpc : "2.0" , method : "initialize" , id : "123" , params : initialize_params } . to_json ,
2004+ )
2005+ init_response = @transport . handle_request ( init_request )
2006+ session_id = init_response [ 1 ] [ "mcp-session-id" ]
2007+
2008+ request = create_rack_request (
2009+ "GET" ,
2010+ "/" ,
2011+ {
2012+ "HTTP_MCP_SESSION_ID" => session_id ,
2013+ "HTTP_ACCEPT" => ",text/event-stream" ,
2014+ } ,
2015+ )
2016+
2017+ response = @transport . handle_request ( request )
2018+ assert_equal 200 , response [ 0 ]
2019+ assert_equal "text/event-stream" , response [ 1 ] [ "content-type" ]
2020+ end
2021+
19812022 test "GET request with Accept: */* succeeds" do
19822023 init_request = create_rack_request (
19832024 "POST" ,
0 commit comments