Merge pull request #359 from koic/case_insensitive_accept_header
Fix case-sensitive Accept header comparison
This commit is contained in:
commit
dd7dacae47
1 changed files with 40 additions and 1 deletions
|
|
@ -1465,6 +1465,45 @@ module MCP
|
|||
assert_equal 200, response[0]
|
||||
end
|
||||
|
||||
test "POST request with mixed-case Accept header succeeds" do
|
||||
request = create_rack_request_without_accept(
|
||||
"POST",
|
||||
"/",
|
||||
{
|
||||
"CONTENT_TYPE" => "application/json",
|
||||
"HTTP_ACCEPT" => "Application/JSON, Text/Event-Stream",
|
||||
},
|
||||
{ jsonrpc: "2.0", method: "initialize", id: "123" }.to_json,
|
||||
)
|
||||
|
||||
response = @transport.handle_request(request)
|
||||
assert_equal 200, response[0]
|
||||
end
|
||||
|
||||
test "GET request with upper-case Accept header succeeds" do
|
||||
init_request = create_rack_request(
|
||||
"POST",
|
||||
"/",
|
||||
{ "CONTENT_TYPE" => "application/json" },
|
||||
{ jsonrpc: "2.0", method: "initialize", id: "123" }.to_json,
|
||||
)
|
||||
init_response = @transport.handle_request(init_request)
|
||||
session_id = init_response[1]["Mcp-Session-Id"]
|
||||
|
||||
request = create_rack_request_without_accept(
|
||||
"GET",
|
||||
"/",
|
||||
{
|
||||
"HTTP_ACCEPT" => "TEXT/EVENT-STREAM",
|
||||
"HTTP_MCP_SESSION_ID" => session_id,
|
||||
},
|
||||
)
|
||||
|
||||
response = @transport.handle_request(request)
|
||||
assert_equal 200, response[0]
|
||||
assert_equal "text/event-stream", response[1]["Content-Type"]
|
||||
end
|
||||
|
||||
test "GET request without Accept header returns 406" do
|
||||
init_request = create_rack_request(
|
||||
"POST",
|
||||
|
|
|
|||
Loading…
Reference in a new issue