You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can get the header keys from Metadata. But the related parsing code from Cookies in private in net/http package. Is there any way those can be exposed from Metadata or net/http package? https://golang.org/src/net/http/cookie.go#L198
Thanks.
The text was updated successfully, but these errors were encountered:
I tried the above code snippet. It does not work. metadata.MD converts headers keys into lower case. On the other hand Request.Header, converts all keys to upper case.So, you need to do the following to make things work:
package auth
import (
"fmt"
"net/http"
"testing"
"google.golang.org/grpc/metadata"
)
func TestGetFromCookie(t *testing.T) {
md := metadata.Pairs("Key-A", "Val-A")
req := &http.Request{
Header: http.Header{},
}
for k, v := range md {
for _, val := range v {
req.Header.Add(k, val)
}
}
// req := &http.Request{Header: http.Header(md)}
fmt.Println(req.Header.Get("Key-A"))
}
We can get the header keys from Metadata. But the related parsing code from Cookies in private in
net/http
package. Is there any way those can be exposed from Metadata ornet/http
package?https://golang.org/src/net/http/cookie.go#L198
Thanks.
The text was updated successfully, but these errors were encountered: