From 275b0a64e599f7d26d156c53d8ffa6f48e9f4818 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 9 Dec 2024 18:02:09 +0300 Subject: [PATCH 1/4] metadata: fix for grpc case Signed-off-by: Vasiliy Tolstov --- metadata/metadata.go | 6 ++++++ metadata/metadata_test.go | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/metadata/metadata.go b/metadata/metadata.go index 7fd26e8a..46744b9a 100644 --- a/metadata/metadata.go +++ b/metadata/metadata.go @@ -4,6 +4,7 @@ package metadata import ( "net/textproto" "sort" + "strings" ) var ( @@ -73,6 +74,9 @@ func (md Metadata) Get(key string) (string, bool) { if !ok { // slow path val, ok = md[textproto.CanonicalMIMEHeaderKey(key)] + if !ok { + val, ok = md[strings.ToLower(key)] + } } return val, ok } @@ -94,6 +98,8 @@ func (md Metadata) Del(keys ...string) { delete(md, key) // slow path delete(md, textproto.CanonicalMIMEHeaderKey(key)) + // very slow path + delete(md, strings.ToLower(key)) } } diff --git a/metadata/metadata_test.go b/metadata/metadata_test.go index 7b6eb885..99afb58c 100644 --- a/metadata/metadata_test.go +++ b/metadata/metadata_test.go @@ -5,6 +5,15 @@ import ( "testing" ) +func TestLowercase(t *testing.T) { + md := New(1) + md["x-request-id"] = "12345" + v, ok := md.Get("X-Request-Id") + if !ok || v == "" { + t.Fatalf("metadata invalid %#+v", md) + } +} + func TestMultipleUsage(t *testing.T) { ctx := context.TODO() md := New(0) -- 2.45.2 From 6dc76cdfea5c593015f4428e9a757c37f4a34d58 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 10 Dec 2024 00:56:52 +0300 Subject: [PATCH 2/4] workflow improve Signed-off-by: Vasiliy Tolstov --- .gitea/workflows/job_lint.yml | 8 +++++--- .gitea/workflows/job_test.yml | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/job_lint.yml b/.gitea/workflows/job_lint.yml index a47bf298..acfc4ed7 100644 --- a/.gitea/workflows/job_lint.yml +++ b/.gitea/workflows/job_lint.yml @@ -12,12 +12,14 @@ jobs: lint: runs-on: ubuntu-latest steps: + - name: checkout + uses: actions/checkout@v4 + with: + filter: 'blob:none' - name: setup-go uses: actions/setup-go@v5 with: - go-version: 'stable' - - name: checkout - uses: actions/checkout@v3 + go-version: 'stable' - name: deps run: go get -v -d ./... - name: lint diff --git a/.gitea/workflows/job_test.yml b/.gitea/workflows/job_test.yml index 15716f1d..0840a4fe 100644 --- a/.gitea/workflows/job_test.yml +++ b/.gitea/workflows/job_test.yml @@ -17,12 +17,14 @@ jobs: test: runs-on: ubuntu-latest steps: + - name: checkout + uses: actions/checkout@v4 + with: + filter: 'blob:none' - name: setup-go uses: actions/setup-go@v5 with: go-version: 'stable' - - name: checkout - uses: actions/checkout@v3 - name: deps run: go get -v -d ./... - name: test -- 2.45.2 From ba4478a5e0e3d22c74b8b614179c0351e2f80fe1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 10 Dec 2024 00:59:54 +0300 Subject: [PATCH 3/4] workflow improve Signed-off-by: Vasiliy Tolstov --- .gitea/workflows/job_lint.yml | 4 ++-- .gitea/workflows/job_test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/job_lint.yml b/.gitea/workflows/job_lint.yml index acfc4ed7..7a160239 100644 --- a/.gitea/workflows/job_lint.yml +++ b/.gitea/workflows/job_lint.yml @@ -14,8 +14,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - with: - filter: 'blob:none' + #with: + # filter: 'blob:none' - name: setup-go uses: actions/setup-go@v5 with: diff --git a/.gitea/workflows/job_test.yml b/.gitea/workflows/job_test.yml index 0840a4fe..2172c132 100644 --- a/.gitea/workflows/job_test.yml +++ b/.gitea/workflows/job_test.yml @@ -19,8 +19,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - with: - filter: 'blob:none' + #with: + # filter: 'blob:none' - name: setup-go uses: actions/setup-go@v5 with: -- 2.45.2 From 90bed77526340e2ff9cc74e98207270296685ea3 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 10 Dec 2024 01:38:30 +0300 Subject: [PATCH 4/4] workflow improve Signed-off-by: Vasiliy Tolstov --- .gitea/workflows/job_lint.yml | 4 ++-- .gitea/workflows/job_test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/job_lint.yml b/.gitea/workflows/job_lint.yml index 7a160239..acfc4ed7 100644 --- a/.gitea/workflows/job_lint.yml +++ b/.gitea/workflows/job_lint.yml @@ -14,8 +14,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - #with: - # filter: 'blob:none' + with: + filter: 'blob:none' - name: setup-go uses: actions/setup-go@v5 with: diff --git a/.gitea/workflows/job_test.yml b/.gitea/workflows/job_test.yml index 2172c132..0840a4fe 100644 --- a/.gitea/workflows/job_test.yml +++ b/.gitea/workflows/job_test.yml @@ -19,8 +19,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - #with: - # filter: 'blob:none' + with: + filter: 'blob:none' - name: setup-go uses: actions/setup-go@v5 with: -- 2.45.2