Merge pull request #359 from koic/case_insensitive_accept_header
Fix case-sensitive Accept header comparison
This commit is contained in:
commit
dd7dacae47
2 changed files with 40 additions and 1 deletions
|
|
@ -504,7 +504,7 @@ module MCP
|
||||||
|
|
||||||
def parse_accept_header(header)
|
def parse_accept_header(header)
|
||||||
header.split(",").map do |part|
|
header.split(",").map do |part|
|
||||||
part.split(";").first.strip
|
part.split(";").first.strip.downcase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1465,6 +1465,45 @@ module MCP
|
||||||
assert_equal 200, response[0]
|
assert_equal 200, response[0]
|
||||||
end
|
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
|
test "GET request without Accept header returns 406" do
|
||||||
init_request = create_rack_request(
|
init_request = create_rack_request(
|
||||||
"POST",
|
"POST",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue