mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-04 13:05:24 -04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df91fb0da9 |
@@ -37,7 +37,7 @@ jobs:
|
||||
# Set the minimum Go patch version for the given Go minor
|
||||
# Usable via ${{ matrix.GO_SEMVER }}
|
||||
- go: '1.26'
|
||||
GO_SEMVER: '~1.26.0'
|
||||
GO_SEMVER: '1.26.4'
|
||||
|
||||
# Set some variables per OS, usable via ${{ matrix.VAR }}
|
||||
# OS_LABEL: the VM label from GitHub Actions (see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories)
|
||||
@@ -235,7 +235,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
|
||||
with:
|
||||
go-version: "~1.26"
|
||||
go-version: "1.26.4"
|
||||
check-latest: true
|
||||
- name: Install xcaddy
|
||||
run: |
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
# Set the minimum Go patch version for the given Go minor
|
||||
# Usable via ${{ matrix.GO_SEMVER }}
|
||||
- go: '1.26'
|
||||
GO_SEMVER: '~1.26.0'
|
||||
GO_SEMVER: '1.26.4'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
|
||||
with:
|
||||
go-version: '~1.26'
|
||||
go-version: '1.26.4'
|
||||
check-latest: true
|
||||
|
||||
- name: golangci-lint
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
- name: govulncheck
|
||||
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
|
||||
with:
|
||||
go-version-input: '~1.26.0'
|
||||
go-version-input: '1.26.4'
|
||||
check-latest: true
|
||||
|
||||
dependency-review:
|
||||
|
||||
@@ -340,7 +340,7 @@ jobs:
|
||||
# Set the minimum Go patch version for the given Go minor
|
||||
# Usable via ${{ matrix.GO_SEMVER }}
|
||||
- go: '1.26'
|
||||
GO_SEMVER: '~1.26.0'
|
||||
GO_SEMVER: '1.26.4'
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
# https://github.com/sigstore/cosign/issues/1258#issuecomment-1002251233
|
||||
|
||||
@@ -70,8 +70,7 @@ func init() {
|
||||
// `{http.request.orig_uri.query}` | The request's original query string (without `?`)
|
||||
// `{http.request.orig_uri.prefixed_query}` | The request's original query string with a `?` prefix, if non-empty
|
||||
// `{http.request.port}` | The port part of the request's Host header
|
||||
// `{http.request.proto}` | The raw protocol of the request as returned by Go (e.g., HTTP/2.0 or HTTP/3.0)
|
||||
// `{http.request.proto_name}` | The spec-defined protocol of the request (e.g., HTTP/2 or HTTP/3)
|
||||
// `{http.request.proto}` | The protocol of the request
|
||||
// `{http.request.local.host}` | The host (IP) part of the local address the connection arrived on
|
||||
// `{http.request.local.port}` | The port part of the local address the connection arrived on
|
||||
// `{http.request.local}` | The local address the connection arrived on
|
||||
|
||||
@@ -105,14 +105,6 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo
|
||||
return "http", true
|
||||
case "http.request.proto":
|
||||
return req.Proto, true
|
||||
case "http.request.proto_name":
|
||||
if req.ProtoMajor == 2 {
|
||||
return "HTTP/2", true
|
||||
}
|
||||
if req.ProtoMajor == 3 {
|
||||
return "HTTP/3", true
|
||||
}
|
||||
return req.Proto, true
|
||||
case "http.request.host":
|
||||
host, _, err := net.SplitHostPort(req.Host)
|
||||
if err != nil {
|
||||
|
||||
@@ -266,33 +266,3 @@ eqp31wM9il1n+guTNyxJd+FzVAH+hCZE5K+tCgVDdVFUlDEHHbS/wqb2PSIoouLV
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPProtoNameNormalization(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
proto string
|
||||
major int
|
||||
expectRaw string
|
||||
expectName string
|
||||
}{
|
||||
{proto: "HTTP/1.0", major: 1, expectRaw: "HTTP/1.0", expectName: "HTTP/1.0"},
|
||||
{proto: "HTTP/1.1", major: 1, expectRaw: "HTTP/1.1", expectName: "HTTP/1.1"},
|
||||
{proto: "HTTP/2.0", major: 2, expectRaw: "HTTP/2.0", expectName: "HTTP/2"},
|
||||
{proto: "HTTP/3.0", major: 3, expectRaw: "HTTP/3.0", expectName: "HTTP/3"},
|
||||
} {
|
||||
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
req.Proto = tc.proto
|
||||
req.ProtoMajor = tc.major
|
||||
repl := caddy.NewReplacer()
|
||||
addHTTPVarsToReplacer(repl, req, nil)
|
||||
|
||||
gotRaw, okRaw := repl.GetString("http.request.proto")
|
||||
if !okRaw || gotRaw != tc.expectRaw {
|
||||
t.Errorf("proto=%s: expected http.request.proto to be %q, got %q (ok=%t)", tc.proto, tc.expectRaw, gotRaw, okRaw)
|
||||
}
|
||||
|
||||
gotName, okName := repl.GetString("http.request.proto_name")
|
||||
if !okName || gotName != tc.expectName {
|
||||
t.Errorf("proto=%s: expected http.request.proto_name to be %q, got %q (ok=%t)", tc.proto, tc.expectName, gotName, okName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user