diff --git a/core/services/ocr2/plugins/ccip/tokendata/http/http_client.go b/core/services/ocr2/plugins/ccip/tokendata/http/http_client.go index d8e80b914c..dd303822c7 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/http/http_client.go +++ b/core/services/ocr2/plugins/ccip/tokendata/http/http_client.go @@ -22,11 +22,11 @@ type IHttpClient interface { type HttpClient struct { } -func (s *HttpClient) Get(ctx context.Context, url string, timeout time.Duration) ([]byte, int, http.Header, error) { +func doRequest(ctx context.Context, url string, requestType string, requestBody io.Reader, timeout time.Duration) ([]byte, int, http.Header, error) { // Use a timeout to guard against attestation API hanging, causing observation timeout and failing to make any progress. timeoutCtx, cancel := context.WithTimeoutCause(ctx, timeout, tokendata.ErrTimeout) defer cancel() - req, err := http.NewRequestWithContext(timeoutCtx, http.MethodGet, url, nil) + req, err := http.NewRequestWithContext(timeoutCtx, requestType, url, requestBody) if err != nil { return nil, http.StatusBadRequest, nil, err } @@ -50,7 +50,10 @@ func (s *HttpClient) Get(ctx context.Context, url string, timeout time.Duration) return body, res.StatusCode, res.Header, err } -func (s *HttpClient) Post(ctx context.Context, url string, requestData io.Reader, timeout time.Duration) ([]byte, int, http.Header, error) { - // TODO: Implement - return nil, 0, nil, nil +func (s *HttpClient) Get(ctx context.Context, url string, timeout time.Duration) ([]byte, int, http.Header, error) { + return doRequest(ctx, url, http.MethodGet, nil, timeout) +} + +func (s *HttpClient) Post(ctx context.Context, url string, requestBody io.Reader, timeout time.Duration) ([]byte, int, http.Header, error) { + return doRequest(ctx, url, http.MethodPost, requestBody, timeout) }