From 2de21eb22fd8c4ffe6fc89143ef424edbee9c220 Mon Sep 17 00:00:00 2001 From: james-prysm <90280386+james-prysm@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:19:42 -0500 Subject: [PATCH] adding headers to post endpoint (#13753) --- api/client/builder/client.go | 6 ++++++ api/client/builder/client_test.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/api/client/builder/client.go b/api/client/builder/client.go index e740dcea1..b9709abcd 100644 --- a/api/client/builder/client.go +++ b/api/client/builder/client.go @@ -304,6 +304,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS } versionOpt := func(r *http.Request) { r.Header.Add("Eth-Consensus-Version", version.String(version.Bellatrix)) + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") } rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt) @@ -341,6 +343,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS } versionOpt := func(r *http.Request) { r.Header.Add("Eth-Consensus-Version", version.String(version.Capella)) + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") } rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt) @@ -379,6 +383,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS versionOpt := func(r *http.Request) { r.Header.Add("Eth-Consensus-Version", version.String(version.Deneb)) + r.Header.Set("Content-Type", "application/json") + r.Header.Set("Accept", "application/json") } rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt) if err != nil { diff --git a/api/client/builder/client_test.go b/api/client/builder/client_test.go index a5dae2648..5131ec716 100644 --- a/api/client/builder/client_test.go +++ b/api/client/builder/client_test.go @@ -321,6 +321,8 @@ func TestSubmitBlindedBlock(t *testing.T) { Transport: roundtrip(func(r *http.Request) (*http.Response, error) { require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path) require.Equal(t, "bellatrix", r.Header.Get("Eth-Consensus-Version")) + require.Equal(t, "application/json", r.Header.Get("Content-Type")) + require.Equal(t, "application/json", r.Header.Get("Accept")) return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayload)), @@ -347,6 +349,8 @@ func TestSubmitBlindedBlock(t *testing.T) { Transport: roundtrip(func(r *http.Request) (*http.Response, error) { require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path) require.Equal(t, "capella", r.Header.Get("Eth-Consensus-Version")) + require.Equal(t, "application/json", r.Header.Get("Content-Type")) + require.Equal(t, "application/json", r.Header.Get("Accept")) return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayloadCapella)), @@ -376,6 +380,8 @@ func TestSubmitBlindedBlock(t *testing.T) { Transport: roundtrip(func(r *http.Request) (*http.Response, error) { require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path) require.Equal(t, "deneb", r.Header.Get("Eth-Consensus-Version")) + require.Equal(t, "application/json", r.Header.Get("Content-Type")) + require.Equal(t, "application/json", r.Header.Get("Accept")) var req structs.SignedBlindedBeaconBlockDeneb err := json.NewDecoder(r.Body).Decode(&req) require.NoError(t, err)