diff --git a/x-pack/filebeat/input/httpjson/input.go b/x-pack/filebeat/input/httpjson/input.go index b2b8d96c656..592f9bce86d 100644 --- a/x-pack/filebeat/input/httpjson/input.go +++ b/x-pack/filebeat/input/httpjson/input.go @@ -126,7 +126,7 @@ func run(ctx v2.Context, cfg config, pub inputcursor.Publisher, crsr *inputcurso metrics := newInputMetrics(reg) - httpClient, err := newHTTPClient(stdCtx, cfg, log, reg) + client, err := newHTTPClient(stdCtx, cfg, log, reg) if err != nil { return err } @@ -144,9 +144,9 @@ func run(ctx v2.Context, cfg config, pub inputcursor.Publisher, crsr *inputcurso return err } } - pagination := newPagination(cfg, httpClient, log) + pagination := newPagination(cfg, client, log) responseProcessor := newResponseProcessor(cfg, pagination, xmlDetails, metrics, log) - requester := newRequester(httpClient, requestFactory, responseProcessor, log) + requester := newRequester(client, requestFactory, responseProcessor, log) trCtx := emptyTransformContext() trCtx.cursor = newCursor(cfg.Cursor, log) diff --git a/x-pack/filebeat/input/httpjson/pagination.go b/x-pack/filebeat/input/httpjson/pagination.go index 459a1528751..cdfcadb0632 100644 --- a/x-pack/filebeat/input/httpjson/pagination.go +++ b/x-pack/filebeat/input/httpjson/pagination.go @@ -20,14 +20,14 @@ import ( const paginationNamespace = "pagination" type pagination struct { - httpClient *httpClient + client *httpClient requestFactory *requestFactory decoder decoderFunc log *logp.Logger } -func newPagination(config config, httpClient *httpClient, log *logp.Logger) *pagination { - pagination := &pagination{httpClient: httpClient, log: log} +func newPagination(config config, client *httpClient, log *logp.Logger) *pagination { + pagination := &pagination{client: client, log: log} if config.Response == nil { return pagination } @@ -138,7 +138,7 @@ func (iter *pageIterator) next() (*response, bool, error) { } //nolint:bodyclose // response body is closed through drainBody method - resp, err := iter.pagination.httpClient.do(iter.stdCtx, httpReq) + resp, err := iter.pagination.client.do(iter.stdCtx, httpReq) if err != nil { return nil, false, err } diff --git a/x-pack/filebeat/input/httpjson/request.go b/x-pack/filebeat/input/httpjson/request.go index cc2b39127f9..3d41d8f73f8 100644 --- a/x-pack/filebeat/input/httpjson/request.go +++ b/x-pack/filebeat/input/httpjson/request.go @@ -219,8 +219,8 @@ func (rf *requestFactory) collectResponse(ctx context.Context, trCtx *transformC return nil, fmt.Errorf("failed to create http request: %w", err) } - if rf.isChain && rf.chainHTTPClient != nil { - httpResp, err = rf.chainHTTPClient.do(ctx, req) + if rf.isChain && rf.chainClient != nil { + httpResp, err = rf.chainClient.do(ctx, req) if err != nil { return nil, fmt.Errorf("failed to execute chain http client.Do: %w", err) } @@ -258,7 +258,7 @@ func (c *httpClient) do(ctx context.Context, req *http.Request) (*http.Response, } type requestFactory struct { - chainHTTPClient *httpClient + chainClient *httpClient url url.URL method string body *mapstr.M @@ -309,7 +309,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met if ch.Step != nil { ts, _ := newBasicTransformsFromConfig(registeredTransforms, ch.Step.Request.Transforms, requestNamespace, log) ch.Step.Auth = tryAssignAuth(config.Auth, ch.Step.Auth) - httpClient, err := newChainHTTPClient(ctx, ch.Step.Auth, ch.Step.Request, log, reg) + client, err := newChainHTTPClient(ctx, ch.Step.Auth, ch.Step.Request, log, reg) if err != nil { return nil, fmt.Errorf("failed in creating chain http client with error : %w", err) } @@ -318,7 +318,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met rf.password = ch.Step.Auth.Basic.Password } - responseProcessor := newChainResponseProcessor(ch, httpClient, xmlDetails, metrics, log) + responseProcessor := newChainResponseProcessor(ch, client, xmlDetails, metrics, log) rf = &requestFactory{ url: *ch.Step.Request.URL.URL, @@ -330,14 +330,14 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met replace: ch.Step.Replace, replaceWith: ch.Step.ReplaceWith, isChain: true, - chainHTTPClient: httpClient, + chainClient: client, chainResponseProcessor: responseProcessor, } } else if ch.While != nil { ts, _ := newBasicTransformsFromConfig(registeredTransforms, ch.While.Request.Transforms, requestNamespace, log) policy := newHTTPPolicy(evaluateResponse, ch.While.Until, log) ch.While.Auth = tryAssignAuth(config.Auth, ch.While.Auth) - httpClient, err := newChainHTTPClient(ctx, ch.While.Auth, ch.While.Request, log, reg, policy) + client, err := newChainHTTPClient(ctx, ch.While.Auth, ch.While.Request, log, reg, policy) if err != nil { return nil, fmt.Errorf("failed in creating chain http client with error : %w", err) } @@ -346,7 +346,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met rf.password = ch.While.Auth.Basic.Password } - responseProcessor := newChainResponseProcessor(ch, httpClient, xmlDetails, metrics, log) + responseProcessor := newChainResponseProcessor(ch, client, xmlDetails, metrics, log) rf = &requestFactory{ url: *ch.While.Request.URL.URL, method: ch.While.Request.Method, @@ -358,7 +358,7 @@ func newRequestFactory(ctx context.Context, config config, log *logp.Logger, met replaceWith: ch.While.ReplaceWith, until: ch.While.Until, isChain: true, - chainHTTPClient: httpClient, + chainClient: client, chainResponseProcessor: responseProcessor, } } diff --git a/x-pack/filebeat/input/httpjson/response.go b/x-pack/filebeat/input/httpjson/response.go index 63ba34d9d9a..8f7ccbd6e55 100644 --- a/x-pack/filebeat/input/httpjson/response.go +++ b/x-pack/filebeat/input/httpjson/response.go @@ -144,8 +144,8 @@ func newResponseProcessor(config config, pagination *pagination, xmlDetails map[ return rps } -func newChainResponseProcessor(config chainConfig, httpClient *httpClient, xmlDetails map[string]xml.Detail, metrics *inputMetrics, log *logp.Logger) *responseProcessor { - pagination := &pagination{httpClient: httpClient, log: log} +func newChainResponseProcessor(config chainConfig, client *httpClient, xmlDetails map[string]xml.Detail, metrics *inputMetrics, log *logp.Logger) *responseProcessor { + pagination := &pagination{client: client, log: log} rp := &responseProcessor{ pagination: pagination,