Repository navigation
Commit 6b08edd
committed
Ignore empty members of the Accept header
## Motivation and Context
An `Accept` header with an empty list member, such as `application/json,,text/event-stream` or one with
a leading comma, makes the Streamable HTTP transport answer a POST with 500 and report a `NoMethodError`
to the exception reporter, and raise out of a GET, although the required media types are listed
(issue #609): `parse_accept_header` splits each member on `;` and an empty member yields nothing to strip.
RFC 9110 section 5.6.1.2 has a recipient parse and ignore a reasonable number of empty list elements,
and the TypeScript and Python servers accept such a header, the one by substring checks and the other by
stripping each member.
`parse_accept_header` now skips empty members, so the POST and GET checks see the media types that are there.
Fixes #609.
## How Has This Been Tested?
Two new tests in `test/mcp/server/transports/streamable_http_transport_test.rb`, a POST with a doubled and
with a leading comma and a GET with a leading comma. Against the previous library the POST test fails with
a 500 and the GET test raises.
## Breaking Changes
None.1 parent 0019b4d commit 6b08edd
2 files changed
Lines changed: 44 additions & 3 deletions
File tree
- lib/mcp/server/transports
- test/mcp/server/transports
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1883 | 1883 | | |
1884 | 1884 | | |
1885 | 1885 | | |
| 1886 | + | |
| 1887 | + | |
1886 | 1888 | | |
1887 | | - | |
1888 | | - | |
1889 | | - | |
| 1889 | + | |
1890 | 1890 | | |
1891 | 1891 | | |
1892 | 1892 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1756 | 1756 | | |
1757 | 1757 | | |
1758 | 1758 | | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
1759 | 1776 | | |
1760 | 1777 | | |
1761 | 1778 | | |
| |||
1886 | 1903 | | |
1887 | 1904 | | |
1888 | 1905 | | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
1889 | 1930 | | |
1890 | 1931 | | |
1891 | 1932 | | |
| |||
0 commit comments