From 4c4a024e198c53c3439e92b52f321527ce791e23 Mon Sep 17 00:00:00 2001 From: pugnack Date: Thu, 5 Jun 2025 14:18:50 +0500 Subject: [PATCH] fix for headers with hyphens (#155) --- http.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/http.go b/http.go index a73219d..364d41c 100644 --- a/http.go +++ b/http.go @@ -5,6 +5,7 @@ import ( "bufio" "bytes" "context" + stderr "errors" "fmt" "io" "net" @@ -177,6 +178,11 @@ func newRequest(ctx context.Context, log logger.Logger, addr string, req client. for km, vm := range parameters { for k, required := range vm { v, err = rutil.StructFieldByPath(msg, k) + if stderr.Is(err, rutil.ErrNotFound) { + // Note: check the `json_name` in the `protobuf` tag for headers with hyphens, + // since struct fields cannot contain hyphens. + v, err = rutil.StructFieldByTag(msg, "protobuf", fmt.Sprintf("json=%s", k)) + } if err != nil { return nil, errors.BadRequest("go.micro.client", "%+v", err) }