mcp: add MCPGPDEBUG for opt-in Content-Type check (#1012)
Copy of existing [PR](https://github.com/modelcontextprotocol/go-sdk/pull/972) patching 1.6.0 version
This commit is contained in:
parent
d9728a88f3
commit
71ffcb412a
1 changed files with 27 additions and 3 deletions
|
|
@ -202,7 +202,7 @@ func (h *SSEHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
// Validate 'Content-Type' header.
|
||||
if req.Method == http.MethodPost {
|
||||
if disablecontenttypecheck != "1" && req.Method == http.MethodPost {
|
||||
mediaType, _, err := mime.ParseMediaType(req.Header.Get("Content-Type"))
|
||||
if err != nil || mediaType != "application/json" {
|
||||
http.Error(w, "Content-Type must be 'application/json'", http.StatusUnsupportedMediaType)
|
||||
|
|
|
|||
Loading…
Reference in a new issue