chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:37:57 +08:00
commit e30f8ba47c
533 changed files with 115926 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
package headers
const (
// AuthorizationHeader is a standard HTTP Header.
AuthorizationHeader = "Authorization"
// ContentTypeHeader is a standard HTTP Header.
ContentTypeHeader = "Content-Type"
// AcceptHeader is a standard HTTP Header.
AcceptHeader = "Accept"
// UserAgentHeader is a standard HTTP Header.
UserAgentHeader = "User-Agent"
// ContentTypeJSON is the standard MIME type for JSON.
ContentTypeJSON = "application/json"
// ContentTypeEventStream is the standard MIME type for Event Streams.
ContentTypeEventStream = "text/event-stream"
// ForwardedForHeader is a standard HTTP Header used to forward the originating IP address of a client.
ForwardedForHeader = "X-Forwarded-For"
// RealIPHeader is a standard HTTP Header used to indicate the real IP address of the client.
RealIPHeader = "X-Real-IP"
// ForwardedHostHeader is a standard HTTP Header for preserving the original Host header when proxying.
ForwardedHostHeader = "X-Forwarded-Host"
// ForwardedProtoHeader is a standard HTTP Header for preserving the original protocol when proxying.
ForwardedProtoHeader = "X-Forwarded-Proto"
// RequestHmacHeader is used to authenticate requests to the Raw API.
RequestHmacHeader = "Request-Hmac"
// MCP-specific headers.
// MCPReadOnlyHeader indicates whether the MCP is in read-only mode.
MCPReadOnlyHeader = "X-MCP-Readonly"
// MCPToolsetsHeader is a comma-separated list of MCP toolsets that the request is for.
MCPToolsetsHeader = "X-MCP-Toolsets"
// MCPToolsHeader is a comma-separated list of MCP tools that the request is for.
MCPToolsHeader = "X-MCP-Tools"
// MCPLockdownHeader indicates whether lockdown mode is enabled.
MCPLockdownHeader = "X-MCP-Lockdown"
// MCPInsidersHeader indicates whether insiders mode is enabled for early access features.
MCPInsidersHeader = "X-MCP-Insiders"
// MCPExcludeToolsHeader is a comma-separated list of MCP tools that should be
// disabled regardless of other settings or header values.
MCPExcludeToolsHeader = "X-MCP-Exclude-Tools"
// MCPFeaturesHeader is a comma-separated list of feature flags to enable.
MCPFeaturesHeader = "X-MCP-Features"
// GitHub-specific headers.
// GraphQLFeaturesHeader is a comma-separated list of GraphQL feature flags to enable for GraphQL requests.
GraphQLFeaturesHeader = "GraphQL-Features"
// GitHubAPIVersionHeader is the header used to specify the GitHub API version.
GitHubAPIVersionHeader = "X-GitHub-Api-Version"
)
+21
View File
@@ -0,0 +1,21 @@
package headers
import "strings"
// ParseCommaSeparated splits a header value by comma, trims whitespace,
// and filters out empty values
func ParseCommaSeparated(value string) []string {
if value == "" {
return []string{}
}
parts := strings.Split(value, ",")
result := make([]string, 0, len(parts))
for _, p := range parts {
trimmed := strings.TrimSpace(p)
if trimmed != "" {
result = append(result, trimmed)
}
}
return result
}
+58
View File
@@ -0,0 +1,58 @@
package headers
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseCommaSeparated(t *testing.T) {
tests := []struct {
name string
input string
expected []string
}{
{
name: "empty string",
input: "",
expected: []string{},
},
{
name: "single value",
input: "foo",
expected: []string{"foo"},
},
{
name: "multiple values",
input: "foo,bar,baz",
expected: []string{"foo", "bar", "baz"},
},
{
name: "whitespace trimmed",
input: " foo , bar , baz ",
expected: []string{"foo", "bar", "baz"},
},
{
name: "empty values filtered",
input: "foo,,bar,",
expected: []string{"foo", "bar"},
},
{
name: "only commas",
input: ",,,",
expected: []string{},
},
{
name: "whitespace only values filtered",
input: "foo, ,bar",
expected: []string{"foo", "bar"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := ParseCommaSeparated(tt.input)
assert.Equal(t, tt.expected, result)
})
}
}