MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / acceptsStreamableHTTP

Function acceptsStreamableHTTP

server/mcp/handler.go:476–504  ·  view source on GitHub ↗
(accept string)

Source from the content-addressed store, hash-verified

474}
475
476func acceptsStreamableHTTP(accept string) bool {
477 if accept == "" {
478 return false
479 }
480 hasJSON := false
481 hasSSE := false
482 for part := range strings.SplitSeq(accept, ",") {
483 mediaType, params, err := mime.ParseMediaType(strings.TrimSpace(part))
484 if err != nil {
485 continue
486 }
487 if q, ok := params["q"]; ok {
488 quality, err := strconv.ParseFloat(q, 64)
489 if err == nil && quality == 0 {
490 continue
491 }
492 }
493 switch mediaType {
494 case "*/*":
495 hasJSON = true
496 hasSSE = true
497 case "application/*", "application/json":
498 hasJSON = true
499 case "text/*", "text/event-stream":
500 hasSSE = true
501 }
502 }
503 return hasJSON || hasSSE
504}
505
506func validateOrigin(r *http.Request) bool {
507 origin := r.Header.Get("Origin")

Callers 1

handlePostMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected