mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
Web3signer: Support json content type with optional metadata (#11058)
* initial commit * wanting to trigger ci
This commit is contained in:
parent
e2442bb0a6
commit
a775798d89
@ -10,6 +10,7 @@ import (
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@ -74,14 +75,13 @@ func (client *ApiClient) Sign(ctx context.Context, pubKey string, request SignRe
|
||||
return nil, fmt.Errorf("signing operation failed due to slashing protection rules, Signing Request URL: %v, Status: %v", client.BaseURL.String()+requestPath, resp.StatusCode)
|
||||
}
|
||||
contentType := resp.Header.Get("Content-Type")
|
||||
switch contentType {
|
||||
case "application/json":
|
||||
if strings.HasPrefix(contentType, "application/json") {
|
||||
var sigResp SignatureResponse
|
||||
if err := unmarshalResponse(resp.Body, &sigResp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bls.SignatureFromBytes(sigResp.Signature)
|
||||
default:
|
||||
} else {
|
||||
return unmarshalSignatureResponse(resp.Body)
|
||||
}
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ func TestClient_Sign_HappyPath_Jsontype(t *testing.T) {
|
||||
}
|
||||
jsonBytes, err := json.Marshal(sigResp)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
// create a new reader with that JSON
|
||||
header := http.Header{
|
||||
"Content-Type": []string{"application/json"},
|
||||
}
|
||||
header := http.Header{}
|
||||
header.Set("Content-Type", "application/json; charset=UTF-8")
|
||||
r := io.NopCloser(bytes.NewReader(jsonBytes))
|
||||
mock := &mockTransport{mockResponse: &http.Response{
|
||||
StatusCode: 200,
|
||||
|
Loading…
Reference in New Issue
Block a user