From 1b4c136a5ef172edc0720985e78296313881427f Mon Sep 17 00:00:00 2001 From: pzl Date: Wed, 5 Oct 2022 16:43:22 -0400 Subject: [PATCH 1/4] API: only set default content-type when not set --- esapi/api.bulk.go | 2 +- esapi/api.clear_scroll.go | 2 +- esapi/api.cluster.allocation_explain.go | 2 +- esapi/api.cluster.put_component_template.go | 2 +- esapi/api.cluster.put_settings.go | 2 +- esapi/api.cluster.reroute.go | 2 +- esapi/api.count.go | 2 +- esapi/api.create.go | 2 +- esapi/api.delete_by_query.go | 2 +- esapi/api.explain.go | 2 +- esapi/api.field_caps.go | 2 +- esapi/api.fleet.msearch.go | 2 +- esapi/api.fleet.search.go | 2 +- esapi/api.index.go | 2 +- esapi/api.indices.analyze.go | 2 +- esapi/api.indices.clone.go | 2 +- esapi/api.indices.create.go | 2 +- esapi/api.indices.modify_data_stream.go | 2 +- esapi/api.indices.put_alias.go | 2 +- esapi/api.indices.put_index_template.go | 2 +- esapi/api.indices.put_mapping.go | 2 +- esapi/api.indices.put_settings.go | 2 +- esapi/api.indices.put_template.go | 2 +- esapi/api.indices.rollover.go | 2 +- esapi/api.indices.shrink.go | 2 +- esapi/api.indices.simulate_index_template.go | 2 +- esapi/api.indices.simulate_template.go | 2 +- esapi/api.indices.split.go | 2 +- esapi/api.indices.update_aliases.go | 2 +- esapi/api.indices.validate_query.go | 2 +- esapi/api.ingest.put_pipeline.go | 2 +- esapi/api.ingest.simulate.go | 2 +- esapi/api.knn_search.go | 2 +- esapi/api.mget.go | 2 +- esapi/api.msearch.go | 2 +- esapi/api.msearch_template.go | 2 +- esapi/api.mtermvectors.go | 2 +- esapi/api.nodes.reload_secure_settings.go | 2 +- esapi/api.put_script.go | 2 +- esapi/api.rank_eval.go | 2 +- esapi/api.reindex.go | 2 +- esapi/api.render_search_template.go | 2 +- esapi/api.scripts_painless_execute.go | 2 +- esapi/api.scroll.go | 2 +- esapi/api.search.go | 2 +- esapi/api.search_mvt.go | 2 +- esapi/api.search_template.go | 2 +- esapi/api.shutdown.put_node.go | 2 +- esapi/api.snapshot.clone.go | 2 +- esapi/api.snapshot.create.go | 2 +- esapi/api.snapshot.create_repository.go | 2 +- esapi/api.snapshot.restore.go | 2 +- esapi/api.terms_enum.go | 2 +- esapi/api.termvectors.go | 2 +- esapi/api.update.go | 2 +- esapi/api.update_by_query.go | 2 +- esapi/api.xpack.async_search.submit.go | 2 +- esapi/api.xpack.autoscaling.put_autoscaling_policy.go | 2 +- esapi/api.xpack.ccr.follow.go | 2 +- esapi/api.xpack.ccr.forget_follower.go | 2 +- esapi/api.xpack.ccr.put_auto_follow_pattern.go | 2 +- esapi/api.xpack.ccr.resume_follow.go | 2 +- esapi/api.xpack.close_point_in_time.go | 2 +- esapi/api.xpack.enrich.put_policy.go | 2 +- esapi/api.xpack.eql.search.go | 2 +- esapi/api.xpack.graph.explore.go | 2 +- esapi/api.xpack.ilm.migrate_to_data_tiers.go | 2 +- esapi/api.xpack.ilm.move_to_step.go | 2 +- esapi/api.xpack.ilm.put_lifecycle.go | 2 +- esapi/api.xpack.license.post.go | 2 +- esapi/api.xpack.logstash.put_pipeline.go | 2 +- esapi/api.xpack.ml.close_job.go | 2 +- esapi/api.xpack.ml.delete_expired_data.go | 2 +- esapi/api.xpack.ml.estimate_model_memory.go | 2 +- esapi/api.xpack.ml.evaluate_data_frame.go | 2 +- esapi/api.xpack.ml.explain_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.flush_job.go | 2 +- esapi/api.xpack.ml.forecast.go | 2 +- esapi/api.xpack.ml.get_buckets.go | 2 +- esapi/api.xpack.ml.get_calendars.go | 2 +- esapi/api.xpack.ml.get_categories.go | 2 +- esapi/api.xpack.ml.get_influencers.go | 2 +- esapi/api.xpack.ml.get_model_snapshots.go | 2 +- esapi/api.xpack.ml.get_overall_buckets.go | 2 +- esapi/api.xpack.ml.get_records.go | 2 +- esapi/api.xpack.ml.infer_trained_model.go | 2 +- esapi/api.xpack.ml.open_job.go | 2 +- esapi/api.xpack.ml.post_calendar_events.go | 2 +- esapi/api.xpack.ml.post_data.go | 2 +- esapi/api.xpack.ml.preview_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.preview_datafeed.go | 2 +- esapi/api.xpack.ml.put_calendar.go | 2 +- esapi/api.xpack.ml.put_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.put_datafeed.go | 2 +- esapi/api.xpack.ml.put_filter.go | 2 +- esapi/api.xpack.ml.put_job.go | 2 +- esapi/api.xpack.ml.put_trained_model.go | 2 +- esapi/api.xpack.ml.put_trained_model_definition_part.go | 2 +- esapi/api.xpack.ml.put_trained_model_vocabulary.go | 2 +- esapi/api.xpack.ml.revert_model_snapshot.go | 2 +- esapi/api.xpack.ml.start_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.start_datafeed.go | 2 +- esapi/api.xpack.ml.stop_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.stop_datafeed.go | 2 +- esapi/api.xpack.ml.stop_trained_model_deployment.go | 2 +- esapi/api.xpack.ml.update_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.update_datafeed.go | 2 +- esapi/api.xpack.ml.update_filter.go | 2 +- esapi/api.xpack.ml.update_job.go | 2 +- esapi/api.xpack.ml.update_model_snapshot.go | 2 +- esapi/api.xpack.ml.validate.go | 2 +- esapi/api.xpack.ml.validate_detector.go | 2 +- esapi/api.xpack.monitoring.bulk.go | 2 +- esapi/api.xpack.rollup.put_job.go | 2 +- esapi/api.xpack.rollup.rollup_search.go | 2 +- esapi/api.xpack.searchable_snapshots.mount.go | 2 +- esapi/api.xpack.security.activate_user_profile.go | 2 +- esapi/api.xpack.security.change_password.go | 2 +- esapi/api.xpack.security.create_api_key.go | 2 +- esapi/api.xpack.security.get_token.go | 2 +- esapi/api.xpack.security.grant_api_key.go | 2 +- esapi/api.xpack.security.has_privileges.go | 2 +- esapi/api.xpack.security.has_privileges_user_profile.go | 2 +- esapi/api.xpack.security.invalidate_api_key.go | 2 +- esapi/api.xpack.security.invalidate_token.go | 2 +- esapi/api.xpack.security.oidc_authenticate.go | 2 +- esapi/api.xpack.security.oidc_logout.go | 2 +- esapi/api.xpack.security.oidc_prepare_authentication.go | 2 +- esapi/api.xpack.security.put_privileges.go | 2 +- esapi/api.xpack.security.put_role.go | 2 +- esapi/api.xpack.security.put_role_mapping.go | 2 +- esapi/api.xpack.security.put_user.go | 2 +- esapi/api.xpack.security.query_api_keys.go | 2 +- esapi/api.xpack.security.saml_authenticate.go | 2 +- esapi/api.xpack.security.saml_complete_logout.go | 2 +- esapi/api.xpack.security.saml_invalidate.go | 2 +- esapi/api.xpack.security.saml_logout.go | 2 +- esapi/api.xpack.security.saml_prepare_authentication.go | 2 +- esapi/api.xpack.security.suggest_user_profiles.go | 2 +- esapi/api.xpack.security.update_api_key.go | 2 +- esapi/api.xpack.security.update_user_profile_data.go | 2 +- esapi/api.xpack.slm.put_lifecycle.go | 2 +- esapi/api.xpack.sql.clear_cursor.go | 2 +- esapi/api.xpack.sql.query.go | 2 +- esapi/api.xpack.sql.translate.go | 2 +- esapi/api.xpack.text_structure.find_structure.go | 2 +- esapi/api.xpack.transform.preview_transform.go | 2 +- esapi/api.xpack.transform.put_transform.go | 2 +- esapi/api.xpack.transform.update_transform.go | 2 +- esapi/api.xpack.watcher.execute_watch.go | 2 +- esapi/api.xpack.watcher.put_watch.go | 2 +- esapi/api.xpack.watcher.query_watches.go | 2 +- internal/build/cmd/generate/commands/gensource/generator.go | 2 +- 153 files changed, 153 insertions(+), 153 deletions(-) diff --git a/esapi/api.bulk.go b/esapi/api.bulk.go index edab153b46..c2084310cb 100644 --- a/esapi/api.bulk.go +++ b/esapi/api.bulk.go @@ -162,7 +162,7 @@ func (r BulkRequest) Do(ctx context.Context, transport Transport) (*Response, er req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.clear_scroll.go b/esapi/api.clear_scroll.go index 128f33fcca..533e5d3a62 100644 --- a/esapi/api.clear_scroll.go +++ b/esapi/api.clear_scroll.go @@ -111,7 +111,7 @@ func (r ClearScrollRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.allocation_explain.go b/esapi/api.cluster.allocation_explain.go index d429898248..aa7465a05b 100644 --- a/esapi/api.cluster.allocation_explain.go +++ b/esapi/api.cluster.allocation_explain.go @@ -114,7 +114,7 @@ func (r ClusterAllocationExplainRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.put_component_template.go b/esapi/api.cluster.put_component_template.go index b99d70023a..eea24bb66b 100644 --- a/esapi/api.cluster.put_component_template.go +++ b/esapi/api.cluster.put_component_template.go @@ -125,7 +125,7 @@ func (r ClusterPutComponentTemplateRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.put_settings.go b/esapi/api.cluster.put_settings.go index 3e18f662af..cb0b6cfc22 100644 --- a/esapi/api.cluster.put_settings.go +++ b/esapi/api.cluster.put_settings.go @@ -120,7 +120,7 @@ func (r ClusterPutSettingsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.reroute.go b/esapi/api.cluster.reroute.go index 8987c51458..3c1fa3d559 100644 --- a/esapi/api.cluster.reroute.go +++ b/esapi/api.cluster.reroute.go @@ -135,7 +135,7 @@ func (r ClusterRerouteRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.count.go b/esapi/api.count.go index b92edaeb38..38fd2ed589 100644 --- a/esapi/api.count.go +++ b/esapi/api.count.go @@ -181,7 +181,7 @@ func (r CountRequest) Do(ctx context.Context, transport Transport) (*Response, e req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.create.go b/esapi/api.create.go index 6dee17e5a0..45097e7199 100644 --- a/esapi/api.create.go +++ b/esapi/api.create.go @@ -150,7 +150,7 @@ func (r CreateRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.delete_by_query.go b/esapi/api.delete_by_query.go index b75ebda9ff..4fa3f90a9f 100644 --- a/esapi/api.delete_by_query.go +++ b/esapi/api.delete_by_query.go @@ -261,7 +261,7 @@ func (r DeleteByQueryRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.explain.go b/esapi/api.explain.go index 82127ae82d..3381f482c0 100644 --- a/esapi/api.explain.go +++ b/esapi/api.explain.go @@ -172,7 +172,7 @@ func (r ExplainRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.field_caps.go b/esapi/api.field_caps.go index 6b44812ca4..470c9fb3cb 100644 --- a/esapi/api.field_caps.go +++ b/esapi/api.field_caps.go @@ -146,7 +146,7 @@ func (r FieldCapsRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.fleet.msearch.go b/esapi/api.fleet.msearch.go index 7515bf5128..c6a859b13b 100644 --- a/esapi/api.fleet.msearch.go +++ b/esapi/api.fleet.msearch.go @@ -111,7 +111,7 @@ func (r FleetMsearchRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.fleet.search.go b/esapi/api.fleet.search.go index 10339f427f..6b1a2f1986 100644 --- a/esapi/api.fleet.search.go +++ b/esapi/api.fleet.search.go @@ -127,7 +127,7 @@ func (r FleetSearchRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.index.go b/esapi/api.index.go index 6fbf93af35..784dd15926 100644 --- a/esapi/api.index.go +++ b/esapi/api.index.go @@ -174,7 +174,7 @@ func (r IndexRequest) Do(ctx context.Context, transport Transport) (*Response, e req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.analyze.go b/esapi/api.indices.analyze.go index a3fd408e69..449fc0aa37 100644 --- a/esapi/api.indices.analyze.go +++ b/esapi/api.indices.analyze.go @@ -113,7 +113,7 @@ func (r IndicesAnalyzeRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.clone.go b/esapi/api.indices.clone.go index 997927a0a1..bd86ddf7ee 100644 --- a/esapi/api.indices.clone.go +++ b/esapi/api.indices.clone.go @@ -128,7 +128,7 @@ func (r IndicesCloneRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.create.go b/esapi/api.indices.create.go index 1e4367d756..a0b568327d 100644 --- a/esapi/api.indices.create.go +++ b/esapi/api.indices.create.go @@ -122,7 +122,7 @@ func (r IndicesCreateRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.modify_data_stream.go b/esapi/api.indices.modify_data_stream.go index 8822a8bcea..0213250bbe 100644 --- a/esapi/api.indices.modify_data_stream.go +++ b/esapi/api.indices.modify_data_stream.go @@ -102,7 +102,7 @@ func (r IndicesModifyDataStreamRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_alias.go b/esapi/api.indices.put_alias.go index b609ab7f69..2f761ff620 100644 --- a/esapi/api.indices.put_alias.go +++ b/esapi/api.indices.put_alias.go @@ -128,7 +128,7 @@ func (r IndicesPutAliasRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_index_template.go b/esapi/api.indices.put_index_template.go index ff8d906bd5..cb2fb61c64 100644 --- a/esapi/api.indices.put_index_template.go +++ b/esapi/api.indices.put_index_template.go @@ -125,7 +125,7 @@ func (r IndicesPutIndexTemplateRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_mapping.go b/esapi/api.indices.put_mapping.go index 7763ce051a..8d136fc268 100644 --- a/esapi/api.indices.put_mapping.go +++ b/esapi/api.indices.put_mapping.go @@ -141,7 +141,7 @@ func (r IndicesPutMappingRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_settings.go b/esapi/api.indices.put_settings.go index f28e3c5f4f..8a7e702462 100644 --- a/esapi/api.indices.put_settings.go +++ b/esapi/api.indices.put_settings.go @@ -147,7 +147,7 @@ func (r IndicesPutSettingsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_template.go b/esapi/api.indices.put_template.go index eaaffe8581..4fce917394 100644 --- a/esapi/api.indices.put_template.go +++ b/esapi/api.indices.put_template.go @@ -125,7 +125,7 @@ func (r IndicesPutTemplateRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.rollover.go b/esapi/api.indices.rollover.go index 685b353c5e..c80667d927 100644 --- a/esapi/api.indices.rollover.go +++ b/esapi/api.indices.rollover.go @@ -136,7 +136,7 @@ func (r IndicesRolloverRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.shrink.go b/esapi/api.indices.shrink.go index 070db1b5e1..8823d588f6 100644 --- a/esapi/api.indices.shrink.go +++ b/esapi/api.indices.shrink.go @@ -128,7 +128,7 @@ func (r IndicesShrinkRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.simulate_index_template.go b/esapi/api.indices.simulate_index_template.go index 47a9abf251..4aa5e84dfc 100644 --- a/esapi/api.indices.simulate_index_template.go +++ b/esapi/api.indices.simulate_index_template.go @@ -127,7 +127,7 @@ func (r IndicesSimulateIndexTemplateRequest) Do(ctx context.Context, transport T req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.simulate_template.go b/esapi/api.indices.simulate_template.go index 16f6ff73d3..45343eb09b 100644 --- a/esapi/api.indices.simulate_template.go +++ b/esapi/api.indices.simulate_template.go @@ -129,7 +129,7 @@ func (r IndicesSimulateTemplateRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.split.go b/esapi/api.indices.split.go index 8149c37835..673cc6aae9 100644 --- a/esapi/api.indices.split.go +++ b/esapi/api.indices.split.go @@ -128,7 +128,7 @@ func (r IndicesSplitRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.update_aliases.go b/esapi/api.indices.update_aliases.go index bc98409403..ed7a061983 100644 --- a/esapi/api.indices.update_aliases.go +++ b/esapi/api.indices.update_aliases.go @@ -114,7 +114,7 @@ func (r IndicesUpdateAliasesRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.validate_query.go b/esapi/api.indices.validate_query.go index 3c1a011769..ac70c8178f 100644 --- a/esapi/api.indices.validate_query.go +++ b/esapi/api.indices.validate_query.go @@ -173,7 +173,7 @@ func (r IndicesValidateQueryRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.ingest.put_pipeline.go b/esapi/api.ingest.put_pipeline.go index cf099d1b84..1aa363da20 100644 --- a/esapi/api.ingest.put_pipeline.go +++ b/esapi/api.ingest.put_pipeline.go @@ -127,7 +127,7 @@ func (r IngestPutPipelineRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.ingest.simulate.go b/esapi/api.ingest.simulate.go index 6bdf657b77..4315ea9297 100644 --- a/esapi/api.ingest.simulate.go +++ b/esapi/api.ingest.simulate.go @@ -120,7 +120,7 @@ func (r IngestSimulateRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.knn_search.go b/esapi/api.knn_search.go index 8d07754f4d..39ee3a22aa 100644 --- a/esapi/api.knn_search.go +++ b/esapi/api.knn_search.go @@ -120,7 +120,7 @@ func (r KnnSearchRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.mget.go b/esapi/api.mget.go index c7ba04630d..f2d1c8fa69 100644 --- a/esapi/api.mget.go +++ b/esapi/api.mget.go @@ -156,7 +156,7 @@ func (r MgetRequest) Do(ctx context.Context, transport Transport) (*Response, er req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.msearch.go b/esapi/api.msearch.go index 7edc214683..4b29a4762a 100644 --- a/esapi/api.msearch.go +++ b/esapi/api.msearch.go @@ -146,7 +146,7 @@ func (r MsearchRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.msearch_template.go b/esapi/api.msearch_template.go index 4fa470f409..8c1fc62dab 100644 --- a/esapi/api.msearch_template.go +++ b/esapi/api.msearch_template.go @@ -138,7 +138,7 @@ func (r MsearchTemplateRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.mtermvectors.go b/esapi/api.mtermvectors.go index 88bc3becf4..12f450ef81 100644 --- a/esapi/api.mtermvectors.go +++ b/esapi/api.mtermvectors.go @@ -171,7 +171,7 @@ func (r MtermvectorsRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.nodes.reload_secure_settings.go b/esapi/api.nodes.reload_secure_settings.go index 57236c2313..4dee4e121c 100644 --- a/esapi/api.nodes.reload_secure_settings.go +++ b/esapi/api.nodes.reload_secure_settings.go @@ -118,7 +118,7 @@ func (r NodesReloadSecureSettingsRequest) Do(ctx context.Context, transport Tran req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.put_script.go b/esapi/api.put_script.go index 7a2d51655e..264cd7b128 100644 --- a/esapi/api.put_script.go +++ b/esapi/api.put_script.go @@ -129,7 +129,7 @@ func (r PutScriptRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.rank_eval.go b/esapi/api.rank_eval.go index 808bf3365e..02266e6505 100644 --- a/esapi/api.rank_eval.go +++ b/esapi/api.rank_eval.go @@ -131,7 +131,7 @@ func (r RankEvalRequest) Do(ctx context.Context, transport Transport) (*Response req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.reindex.go b/esapi/api.reindex.go index 4da9717786..3a181f1cfd 100644 --- a/esapi/api.reindex.go +++ b/esapi/api.reindex.go @@ -148,7 +148,7 @@ func (r ReindexRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.render_search_template.go b/esapi/api.render_search_template.go index 3e580bfae7..d300a54d07 100644 --- a/esapi/api.render_search_template.go +++ b/esapi/api.render_search_template.go @@ -111,7 +111,7 @@ func (r RenderSearchTemplateRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.scripts_painless_execute.go b/esapi/api.scripts_painless_execute.go index b79cc7e45f..029ef17d78 100644 --- a/esapi/api.scripts_painless_execute.go +++ b/esapi/api.scripts_painless_execute.go @@ -104,7 +104,7 @@ func (r ScriptsPainlessExecuteRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.scroll.go b/esapi/api.scroll.go index 999f99ede8..be7c8eaa28 100644 --- a/esapi/api.scroll.go +++ b/esapi/api.scroll.go @@ -120,7 +120,7 @@ func (r ScrollRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.search.go b/esapi/api.search.go index 80e0a4565b..859a9e7346 100644 --- a/esapi/api.search.go +++ b/esapi/api.search.go @@ -333,7 +333,7 @@ func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.search_mvt.go b/esapi/api.search_mvt.go index 553c3f2888..aca255f464 100644 --- a/esapi/api.search_mvt.go +++ b/esapi/api.search_mvt.go @@ -174,7 +174,7 @@ func (r SearchMvtRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.search_template.go b/esapi/api.search_template.go index 4edd21acaf..3fe83ce1fb 100644 --- a/esapi/api.search_template.go +++ b/esapi/api.search_template.go @@ -179,7 +179,7 @@ func (r SearchTemplateRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.shutdown.put_node.go b/esapi/api.shutdown.put_node.go index fcc5d71797..eaa3a8a6c5 100644 --- a/esapi/api.shutdown.put_node.go +++ b/esapi/api.shutdown.put_node.go @@ -109,7 +109,7 @@ func (r ShutdownPutNodeRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.clone.go b/esapi/api.snapshot.clone.go index b2e93dae6a..6ea0a97542 100644 --- a/esapi/api.snapshot.clone.go +++ b/esapi/api.snapshot.clone.go @@ -122,7 +122,7 @@ func (r SnapshotCloneRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.create.go b/esapi/api.snapshot.create.go index 61d96bf89a..d4f24ca6e0 100644 --- a/esapi/api.snapshot.create.go +++ b/esapi/api.snapshot.create.go @@ -123,7 +123,7 @@ func (r SnapshotCreateRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.create_repository.go b/esapi/api.snapshot.create_repository.go index a2a9ac3002..1cceeb1c5d 100644 --- a/esapi/api.snapshot.create_repository.go +++ b/esapi/api.snapshot.create_repository.go @@ -125,7 +125,7 @@ func (r SnapshotCreateRepositoryRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.restore.go b/esapi/api.snapshot.restore.go index a5bb412b10..2b04e6b3db 100644 --- a/esapi/api.snapshot.restore.go +++ b/esapi/api.snapshot.restore.go @@ -125,7 +125,7 @@ func (r SnapshotRestoreRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.terms_enum.go b/esapi/api.terms_enum.go index 6393d6a32f..f028368190 100644 --- a/esapi/api.terms_enum.go +++ b/esapi/api.terms_enum.go @@ -112,7 +112,7 @@ func (r TermsEnumRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.termvectors.go b/esapi/api.termvectors.go index d7504160a5..d0f95f6cd9 100644 --- a/esapi/api.termvectors.go +++ b/esapi/api.termvectors.go @@ -169,7 +169,7 @@ func (r TermvectorsRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.update.go b/esapi/api.update.go index 950f12d7f5..69176eff36 100644 --- a/esapi/api.update.go +++ b/esapi/api.update.go @@ -173,7 +173,7 @@ func (r UpdateRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.update_by_query.go b/esapi/api.update_by_query.go index 46836f6b15..185075933f 100644 --- a/esapi/api.update_by_query.go +++ b/esapi/api.update_by_query.go @@ -272,7 +272,7 @@ func (r UpdateByQueryRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.async_search.submit.go b/esapi/api.xpack.async_search.submit.go index 4cb869f586..e777762fd4 100644 --- a/esapi/api.xpack.async_search.submit.go +++ b/esapi/api.xpack.async_search.submit.go @@ -318,7 +318,7 @@ func (r AsyncSearchSubmitRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.autoscaling.put_autoscaling_policy.go b/esapi/api.xpack.autoscaling.put_autoscaling_policy.go index bd47be8c04..129ec7abf4 100644 --- a/esapi/api.xpack.autoscaling.put_autoscaling_policy.go +++ b/esapi/api.xpack.autoscaling.put_autoscaling_policy.go @@ -109,7 +109,7 @@ func (r AutoscalingPutAutoscalingPolicyRequest) Do(ctx context.Context, transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.follow.go b/esapi/api.xpack.ccr.follow.go index 69a97ebc5c..61896d2aa8 100644 --- a/esapi/api.xpack.ccr.follow.go +++ b/esapi/api.xpack.ccr.follow.go @@ -115,7 +115,7 @@ func (r CCRFollowRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.forget_follower.go b/esapi/api.xpack.ccr.forget_follower.go index 518bdbdcd2..caebf9a218 100644 --- a/esapi/api.xpack.ccr.forget_follower.go +++ b/esapi/api.xpack.ccr.forget_follower.go @@ -109,7 +109,7 @@ func (r CCRForgetFollowerRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.put_auto_follow_pattern.go b/esapi/api.xpack.ccr.put_auto_follow_pattern.go index 6011c2c44e..fcb6c05ce4 100644 --- a/esapi/api.xpack.ccr.put_auto_follow_pattern.go +++ b/esapi/api.xpack.ccr.put_auto_follow_pattern.go @@ -109,7 +109,7 @@ func (r CCRPutAutoFollowPatternRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.resume_follow.go b/esapi/api.xpack.ccr.resume_follow.go index 810236f654..f0416d2cdc 100644 --- a/esapi/api.xpack.ccr.resume_follow.go +++ b/esapi/api.xpack.ccr.resume_follow.go @@ -109,7 +109,7 @@ func (r CCRResumeFollowRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.close_point_in_time.go b/esapi/api.xpack.close_point_in_time.go index 6b85f9a8ce..f31ac5602e 100644 --- a/esapi/api.xpack.close_point_in_time.go +++ b/esapi/api.xpack.close_point_in_time.go @@ -102,7 +102,7 @@ func (r ClosePointInTimeRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.enrich.put_policy.go b/esapi/api.xpack.enrich.put_policy.go index 88d2d54703..c4a65b8059 100644 --- a/esapi/api.xpack.enrich.put_policy.go +++ b/esapi/api.xpack.enrich.put_policy.go @@ -109,7 +109,7 @@ func (r EnrichPutPolicyRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.eql.search.go b/esapi/api.xpack.eql.search.go index 3e1ea48a42..07acd7dd15 100644 --- a/esapi/api.xpack.eql.search.go +++ b/esapi/api.xpack.eql.search.go @@ -127,7 +127,7 @@ func (r EqlSearchRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.graph.explore.go b/esapi/api.xpack.graph.explore.go index d9a5ffa115..1db48f4b20 100644 --- a/esapi/api.xpack.graph.explore.go +++ b/esapi/api.xpack.graph.explore.go @@ -126,7 +126,7 @@ func (r GraphExploreRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ilm.migrate_to_data_tiers.go b/esapi/api.xpack.ilm.migrate_to_data_tiers.go index a77c4e411f..fac5b03613 100644 --- a/esapi/api.xpack.ilm.migrate_to_data_tiers.go +++ b/esapi/api.xpack.ilm.migrate_to_data_tiers.go @@ -109,7 +109,7 @@ func (r ILMMigrateToDataTiersRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ilm.move_to_step.go b/esapi/api.xpack.ilm.move_to_step.go index 6f92760027..f28e8aac3f 100644 --- a/esapi/api.xpack.ilm.move_to_step.go +++ b/esapi/api.xpack.ilm.move_to_step.go @@ -109,7 +109,7 @@ func (r ILMMoveToStepRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ilm.put_lifecycle.go b/esapi/api.xpack.ilm.put_lifecycle.go index 4907e3df62..a67756f022 100644 --- a/esapi/api.xpack.ilm.put_lifecycle.go +++ b/esapi/api.xpack.ilm.put_lifecycle.go @@ -109,7 +109,7 @@ func (r ILMPutLifecycleRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.license.post.go b/esapi/api.xpack.license.post.go index 88e9eecfe6..0b0c0f57f3 100644 --- a/esapi/api.xpack.license.post.go +++ b/esapi/api.xpack.license.post.go @@ -109,7 +109,7 @@ func (r LicensePostRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.logstash.put_pipeline.go b/esapi/api.xpack.logstash.put_pipeline.go index b60a16ee9e..562e2f6fae 100644 --- a/esapi/api.xpack.logstash.put_pipeline.go +++ b/esapi/api.xpack.logstash.put_pipeline.go @@ -109,7 +109,7 @@ func (r LogstashPutPipelineRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.close_job.go b/esapi/api.xpack.ml.close_job.go index fe8bcb793d..a0d199cbe3 100644 --- a/esapi/api.xpack.ml.close_job.go +++ b/esapi/api.xpack.ml.close_job.go @@ -129,7 +129,7 @@ func (r MLCloseJobRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.delete_expired_data.go b/esapi/api.xpack.ml.delete_expired_data.go index 9fedad9861..1295653052 100644 --- a/esapi/api.xpack.ml.delete_expired_data.go +++ b/esapi/api.xpack.ml.delete_expired_data.go @@ -124,7 +124,7 @@ func (r MLDeleteExpiredDataRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.estimate_model_memory.go b/esapi/api.xpack.ml.estimate_model_memory.go index 2970adf240..dac6d256ca 100644 --- a/esapi/api.xpack.ml.estimate_model_memory.go +++ b/esapi/api.xpack.ml.estimate_model_memory.go @@ -102,7 +102,7 @@ func (r MLEstimateModelMemoryRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.evaluate_data_frame.go b/esapi/api.xpack.ml.evaluate_data_frame.go index 2b73050321..9fec7263ef 100644 --- a/esapi/api.xpack.ml.evaluate_data_frame.go +++ b/esapi/api.xpack.ml.evaluate_data_frame.go @@ -102,7 +102,7 @@ func (r MLEvaluateDataFrameRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.explain_data_frame_analytics.go b/esapi/api.xpack.ml.explain_data_frame_analytics.go index beedad544b..a07577d270 100644 --- a/esapi/api.xpack.ml.explain_data_frame_analytics.go +++ b/esapi/api.xpack.ml.explain_data_frame_analytics.go @@ -115,7 +115,7 @@ func (r MLExplainDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.flush_job.go b/esapi/api.xpack.ml.flush_job.go index 010d944000..7067defce4 100644 --- a/esapi/api.xpack.ml.flush_job.go +++ b/esapi/api.xpack.ml.flush_job.go @@ -138,7 +138,7 @@ func (r MLFlushJobRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.forecast.go b/esapi/api.xpack.ml.forecast.go index 8eb54fb74b..4141efada1 100644 --- a/esapi/api.xpack.ml.forecast.go +++ b/esapi/api.xpack.ml.forecast.go @@ -128,7 +128,7 @@ func (r MLForecastRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_buckets.go b/esapi/api.xpack.ml.get_buckets.go index 79f9dff47c..8b9fd97b44 100644 --- a/esapi/api.xpack.ml.get_buckets.go +++ b/esapi/api.xpack.ml.get_buckets.go @@ -166,7 +166,7 @@ func (r MLGetBucketsRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_calendars.go b/esapi/api.xpack.ml.get_calendars.go index f081f11f9b..6a67e60034 100644 --- a/esapi/api.xpack.ml.get_calendars.go +++ b/esapi/api.xpack.ml.get_calendars.go @@ -123,7 +123,7 @@ func (r MLGetCalendarsRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_categories.go b/esapi/api.xpack.ml.get_categories.go index be1863924a..b9d967d5c0 100644 --- a/esapi/api.xpack.ml.get_categories.go +++ b/esapi/api.xpack.ml.get_categories.go @@ -137,7 +137,7 @@ func (r MLGetCategoriesRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_influencers.go b/esapi/api.xpack.ml.get_influencers.go index 3842b29fde..6554636f8b 100644 --- a/esapi/api.xpack.ml.get_influencers.go +++ b/esapi/api.xpack.ml.get_influencers.go @@ -156,7 +156,7 @@ func (r MLGetInfluencersRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_model_snapshots.go b/esapi/api.xpack.ml.get_model_snapshots.go index 6a9d1f8081..6d504ef7b8 100644 --- a/esapi/api.xpack.ml.get_model_snapshots.go +++ b/esapi/api.xpack.ml.get_model_snapshots.go @@ -149,7 +149,7 @@ func (r MLGetModelSnapshotsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_overall_buckets.go b/esapi/api.xpack.ml.get_overall_buckets.go index 84c6fc3d1d..053754ddb5 100644 --- a/esapi/api.xpack.ml.get_overall_buckets.go +++ b/esapi/api.xpack.ml.get_overall_buckets.go @@ -151,7 +151,7 @@ func (r MLGetOverallBucketsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_records.go b/esapi/api.xpack.ml.get_records.go index 4949d6fe06..7def93e246 100644 --- a/esapi/api.xpack.ml.get_records.go +++ b/esapi/api.xpack.ml.get_records.go @@ -156,7 +156,7 @@ func (r MLGetRecordsRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.infer_trained_model.go b/esapi/api.xpack.ml.infer_trained_model.go index 456fee512c..b5886a591e 100644 --- a/esapi/api.xpack.ml.infer_trained_model.go +++ b/esapi/api.xpack.ml.infer_trained_model.go @@ -122,7 +122,7 @@ func (r MLInferTrainedModelRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.open_job.go b/esapi/api.xpack.ml.open_job.go index cd12915f94..b17bc93039 100644 --- a/esapi/api.xpack.ml.open_job.go +++ b/esapi/api.xpack.ml.open_job.go @@ -111,7 +111,7 @@ func (r MLOpenJobRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.post_calendar_events.go b/esapi/api.xpack.ml.post_calendar_events.go index f51fed7a8b..2c51a1601f 100644 --- a/esapi/api.xpack.ml.post_calendar_events.go +++ b/esapi/api.xpack.ml.post_calendar_events.go @@ -111,7 +111,7 @@ func (r MLPostCalendarEventsRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.post_data.go b/esapi/api.xpack.ml.post_data.go index 09e862ac2d..ab0c464317 100644 --- a/esapi/api.xpack.ml.post_data.go +++ b/esapi/api.xpack.ml.post_data.go @@ -122,7 +122,7 @@ func (r MLPostDataRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.preview_data_frame_analytics.go b/esapi/api.xpack.ml.preview_data_frame_analytics.go index a597ba805a..f9f265d0b5 100644 --- a/esapi/api.xpack.ml.preview_data_frame_analytics.go +++ b/esapi/api.xpack.ml.preview_data_frame_analytics.go @@ -115,7 +115,7 @@ func (r MLPreviewDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.preview_datafeed.go b/esapi/api.xpack.ml.preview_datafeed.go index 194d6f910a..bdee6f2843 100644 --- a/esapi/api.xpack.ml.preview_datafeed.go +++ b/esapi/api.xpack.ml.preview_datafeed.go @@ -124,7 +124,7 @@ func (r MLPreviewDatafeedRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_calendar.go b/esapi/api.xpack.ml.put_calendar.go index 9ff498cc33..283c0ff5ae 100644 --- a/esapi/api.xpack.ml.put_calendar.go +++ b/esapi/api.xpack.ml.put_calendar.go @@ -109,7 +109,7 @@ func (r MLPutCalendarRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_data_frame_analytics.go b/esapi/api.xpack.ml.put_data_frame_analytics.go index 29eaceee8d..cf4a062f1b 100644 --- a/esapi/api.xpack.ml.put_data_frame_analytics.go +++ b/esapi/api.xpack.ml.put_data_frame_analytics.go @@ -111,7 +111,7 @@ func (r MLPutDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_datafeed.go b/esapi/api.xpack.ml.put_datafeed.go index 96233c52dc..f43dd5fad1 100644 --- a/esapi/api.xpack.ml.put_datafeed.go +++ b/esapi/api.xpack.ml.put_datafeed.go @@ -131,7 +131,7 @@ func (r MLPutDatafeedRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_filter.go b/esapi/api.xpack.ml.put_filter.go index 24206bc692..baf64c64ab 100644 --- a/esapi/api.xpack.ml.put_filter.go +++ b/esapi/api.xpack.ml.put_filter.go @@ -109,7 +109,7 @@ func (r MLPutFilterRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_job.go b/esapi/api.xpack.ml.put_job.go index 5c88ddcb4a..437b8691c3 100644 --- a/esapi/api.xpack.ml.put_job.go +++ b/esapi/api.xpack.ml.put_job.go @@ -131,7 +131,7 @@ func (r MLPutJobRequest) Do(ctx context.Context, transport Transport) (*Response req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_trained_model.go b/esapi/api.xpack.ml.put_trained_model.go index 2bdd61dede..2eee7c749c 100644 --- a/esapi/api.xpack.ml.put_trained_model.go +++ b/esapi/api.xpack.ml.put_trained_model.go @@ -116,7 +116,7 @@ func (r MLPutTrainedModelRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_trained_model_definition_part.go b/esapi/api.xpack.ml.put_trained_model_definition_part.go index 84d8faebd5..d6789f768f 100644 --- a/esapi/api.xpack.ml.put_trained_model_definition_part.go +++ b/esapi/api.xpack.ml.put_trained_model_definition_part.go @@ -122,7 +122,7 @@ func (r MLPutTrainedModelDefinitionPartRequest) Do(ctx context.Context, transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_trained_model_vocabulary.go b/esapi/api.xpack.ml.put_trained_model_vocabulary.go index 3fa31573c4..a7efd4a916 100644 --- a/esapi/api.xpack.ml.put_trained_model_vocabulary.go +++ b/esapi/api.xpack.ml.put_trained_model_vocabulary.go @@ -113,7 +113,7 @@ func (r MLPutTrainedModelVocabularyRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.revert_model_snapshot.go b/esapi/api.xpack.ml.revert_model_snapshot.go index 3d933d5051..851d491c05 100644 --- a/esapi/api.xpack.ml.revert_model_snapshot.go +++ b/esapi/api.xpack.ml.revert_model_snapshot.go @@ -123,7 +123,7 @@ func (r MLRevertModelSnapshotRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.start_data_frame_analytics.go b/esapi/api.xpack.ml.start_data_frame_analytics.go index b5e356ddd2..ab77ba1409 100644 --- a/esapi/api.xpack.ml.start_data_frame_analytics.go +++ b/esapi/api.xpack.ml.start_data_frame_analytics.go @@ -120,7 +120,7 @@ func (r MLStartDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tran req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.start_datafeed.go b/esapi/api.xpack.ml.start_datafeed.go index 9b993770ad..1e8c32affc 100644 --- a/esapi/api.xpack.ml.start_datafeed.go +++ b/esapi/api.xpack.ml.start_datafeed.go @@ -128,7 +128,7 @@ func (r MLStartDatafeedRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.stop_data_frame_analytics.go b/esapi/api.xpack.ml.stop_data_frame_analytics.go index 42208b0c3c..c71f213015 100644 --- a/esapi/api.xpack.ml.stop_data_frame_analytics.go +++ b/esapi/api.xpack.ml.stop_data_frame_analytics.go @@ -131,7 +131,7 @@ func (r MLStopDataFrameAnalyticsRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.stop_datafeed.go b/esapi/api.xpack.ml.stop_datafeed.go index f2dc98929b..58401b5ed5 100644 --- a/esapi/api.xpack.ml.stop_datafeed.go +++ b/esapi/api.xpack.ml.stop_datafeed.go @@ -134,7 +134,7 @@ func (r MLStopDatafeedRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.stop_trained_model_deployment.go b/esapi/api.xpack.ml.stop_trained_model_deployment.go index 764232763f..0cb48d63f5 100644 --- a/esapi/api.xpack.ml.stop_trained_model_deployment.go +++ b/esapi/api.xpack.ml.stop_trained_model_deployment.go @@ -127,7 +127,7 @@ func (r MLStopTrainedModelDeploymentRequest) Do(ctx context.Context, transport T req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_data_frame_analytics.go b/esapi/api.xpack.ml.update_data_frame_analytics.go index dfe43c6bb4..f7ef050b6b 100644 --- a/esapi/api.xpack.ml.update_data_frame_analytics.go +++ b/esapi/api.xpack.ml.update_data_frame_analytics.go @@ -113,7 +113,7 @@ func (r MLUpdateDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tra req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_datafeed.go b/esapi/api.xpack.ml.update_datafeed.go index 510e0a37fa..f2ce2fc745 100644 --- a/esapi/api.xpack.ml.update_datafeed.go +++ b/esapi/api.xpack.ml.update_datafeed.go @@ -133,7 +133,7 @@ func (r MLUpdateDatafeedRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_filter.go b/esapi/api.xpack.ml.update_filter.go index 983d793203..b20105018e 100644 --- a/esapi/api.xpack.ml.update_filter.go +++ b/esapi/api.xpack.ml.update_filter.go @@ -111,7 +111,7 @@ func (r MLUpdateFilterRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_job.go b/esapi/api.xpack.ml.update_job.go index ae23d6621b..bc871b37bf 100644 --- a/esapi/api.xpack.ml.update_job.go +++ b/esapi/api.xpack.ml.update_job.go @@ -111,7 +111,7 @@ func (r MLUpdateJobRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_model_snapshot.go b/esapi/api.xpack.ml.update_model_snapshot.go index 2cc4b94594..9aa025527b 100644 --- a/esapi/api.xpack.ml.update_model_snapshot.go +++ b/esapi/api.xpack.ml.update_model_snapshot.go @@ -116,7 +116,7 @@ func (r MLUpdateModelSnapshotRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.validate.go b/esapi/api.xpack.ml.validate.go index 4520696df2..9fb5037ce0 100644 --- a/esapi/api.xpack.ml.validate.go +++ b/esapi/api.xpack.ml.validate.go @@ -102,7 +102,7 @@ func (r MLValidateRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.validate_detector.go b/esapi/api.xpack.ml.validate_detector.go index 3bc77ed7c5..eddbdc742d 100644 --- a/esapi/api.xpack.ml.validate_detector.go +++ b/esapi/api.xpack.ml.validate_detector.go @@ -102,7 +102,7 @@ func (r MLValidateDetectorRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.monitoring.bulk.go b/esapi/api.xpack.monitoring.bulk.go index feb4bd6171..5094b49284 100644 --- a/esapi/api.xpack.monitoring.bulk.go +++ b/esapi/api.xpack.monitoring.bulk.go @@ -127,7 +127,7 @@ func (r MonitoringBulkRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.rollup.put_job.go b/esapi/api.xpack.rollup.put_job.go index 6777bab03c..7d6fb060a5 100644 --- a/esapi/api.xpack.rollup.put_job.go +++ b/esapi/api.xpack.rollup.put_job.go @@ -111,7 +111,7 @@ func (r RollupPutJobRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.rollup.rollup_search.go b/esapi/api.xpack.rollup.rollup_search.go index b691fc7b02..c5cc3ce9f3 100644 --- a/esapi/api.xpack.rollup.rollup_search.go +++ b/esapi/api.xpack.rollup.rollup_search.go @@ -126,7 +126,7 @@ func (r RollupRollupSearchRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.searchable_snapshots.mount.go b/esapi/api.xpack.searchable_snapshots.mount.go index db834c8b23..20c5442aff 100644 --- a/esapi/api.xpack.searchable_snapshots.mount.go +++ b/esapi/api.xpack.searchable_snapshots.mount.go @@ -130,7 +130,7 @@ func (r SearchableSnapshotsMountRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.activate_user_profile.go b/esapi/api.xpack.security.activate_user_profile.go index 3ad0ff6a86..79e8f0a9d8 100644 --- a/esapi/api.xpack.security.activate_user_profile.go +++ b/esapi/api.xpack.security.activate_user_profile.go @@ -104,7 +104,7 @@ func (r SecurityActivateUserProfileRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.change_password.go b/esapi/api.xpack.security.change_password.go index 60ac95d61c..f8641a0e7a 100644 --- a/esapi/api.xpack.security.change_password.go +++ b/esapi/api.xpack.security.change_password.go @@ -119,7 +119,7 @@ func (r SecurityChangePasswordRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.create_api_key.go b/esapi/api.xpack.security.create_api_key.go index 89edb774b1..0f1af44e0d 100644 --- a/esapi/api.xpack.security.create_api_key.go +++ b/esapi/api.xpack.security.create_api_key.go @@ -108,7 +108,7 @@ func (r SecurityCreateAPIKeyRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.get_token.go b/esapi/api.xpack.security.get_token.go index 0894af59a3..8cd0a38f6e 100644 --- a/esapi/api.xpack.security.get_token.go +++ b/esapi/api.xpack.security.get_token.go @@ -102,7 +102,7 @@ func (r SecurityGetTokenRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.grant_api_key.go b/esapi/api.xpack.security.grant_api_key.go index 5c26bf8868..acdfdf6cf7 100644 --- a/esapi/api.xpack.security.grant_api_key.go +++ b/esapi/api.xpack.security.grant_api_key.go @@ -108,7 +108,7 @@ func (r SecurityGrantAPIKeyRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.has_privileges.go b/esapi/api.xpack.security.has_privileges.go index 068aea5900..c860daa51e 100644 --- a/esapi/api.xpack.security.has_privileges.go +++ b/esapi/api.xpack.security.has_privileges.go @@ -113,7 +113,7 @@ func (r SecurityHasPrivilegesRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.has_privileges_user_profile.go b/esapi/api.xpack.security.has_privileges_user_profile.go index 8c456cb87a..170ccf5631 100644 --- a/esapi/api.xpack.security.has_privileges_user_profile.go +++ b/esapi/api.xpack.security.has_privileges_user_profile.go @@ -104,7 +104,7 @@ func (r SecurityHasPrivilegesUserProfileRequest) Do(ctx context.Context, transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.invalidate_api_key.go b/esapi/api.xpack.security.invalidate_api_key.go index cf965d0e19..3551b9ac8b 100644 --- a/esapi/api.xpack.security.invalidate_api_key.go +++ b/esapi/api.xpack.security.invalidate_api_key.go @@ -102,7 +102,7 @@ func (r SecurityInvalidateAPIKeyRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.invalidate_token.go b/esapi/api.xpack.security.invalidate_token.go index c04d5e8151..5a2ac247fe 100644 --- a/esapi/api.xpack.security.invalidate_token.go +++ b/esapi/api.xpack.security.invalidate_token.go @@ -102,7 +102,7 @@ func (r SecurityInvalidateTokenRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.oidc_authenticate.go b/esapi/api.xpack.security.oidc_authenticate.go index 0ef19a9083..92b8d5b684 100644 --- a/esapi/api.xpack.security.oidc_authenticate.go +++ b/esapi/api.xpack.security.oidc_authenticate.go @@ -102,7 +102,7 @@ func (r SecurityOidcAuthenticateRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.oidc_logout.go b/esapi/api.xpack.security.oidc_logout.go index e8c965b878..1e047ce80b 100644 --- a/esapi/api.xpack.security.oidc_logout.go +++ b/esapi/api.xpack.security.oidc_logout.go @@ -102,7 +102,7 @@ func (r SecurityOidcLogoutRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.oidc_prepare_authentication.go b/esapi/api.xpack.security.oidc_prepare_authentication.go index c1587fc91b..3e1bc7664a 100644 --- a/esapi/api.xpack.security.oidc_prepare_authentication.go +++ b/esapi/api.xpack.security.oidc_prepare_authentication.go @@ -102,7 +102,7 @@ func (r SecurityOidcPrepareAuthenticationRequest) Do(ctx context.Context, transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_privileges.go b/esapi/api.xpack.security.put_privileges.go index 9ef2fc5e28..030b616259 100644 --- a/esapi/api.xpack.security.put_privileges.go +++ b/esapi/api.xpack.security.put_privileges.go @@ -108,7 +108,7 @@ func (r SecurityPutPrivilegesRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_role.go b/esapi/api.xpack.security.put_role.go index c5a35dbda6..c29e39971c 100644 --- a/esapi/api.xpack.security.put_role.go +++ b/esapi/api.xpack.security.put_role.go @@ -115,7 +115,7 @@ func (r SecurityPutRoleRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_role_mapping.go b/esapi/api.xpack.security.put_role_mapping.go index 1409d243a6..92146060e6 100644 --- a/esapi/api.xpack.security.put_role_mapping.go +++ b/esapi/api.xpack.security.put_role_mapping.go @@ -115,7 +115,7 @@ func (r SecurityPutRoleMappingRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_user.go b/esapi/api.xpack.security.put_user.go index 5739bfaa15..98f17a7130 100644 --- a/esapi/api.xpack.security.put_user.go +++ b/esapi/api.xpack.security.put_user.go @@ -115,7 +115,7 @@ func (r SecurityPutUserRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.query_api_keys.go b/esapi/api.xpack.security.query_api_keys.go index 1b6290b8b5..ee47cdbd87 100644 --- a/esapi/api.xpack.security.query_api_keys.go +++ b/esapi/api.xpack.security.query_api_keys.go @@ -102,7 +102,7 @@ func (r SecurityQueryAPIKeysRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_authenticate.go b/esapi/api.xpack.security.saml_authenticate.go index fda56e9ca8..ebf39de440 100644 --- a/esapi/api.xpack.security.saml_authenticate.go +++ b/esapi/api.xpack.security.saml_authenticate.go @@ -102,7 +102,7 @@ func (r SecuritySamlAuthenticateRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_complete_logout.go b/esapi/api.xpack.security.saml_complete_logout.go index b0780e32ae..79fbc2b5d5 100644 --- a/esapi/api.xpack.security.saml_complete_logout.go +++ b/esapi/api.xpack.security.saml_complete_logout.go @@ -102,7 +102,7 @@ func (r SecuritySamlCompleteLogoutRequest) Do(ctx context.Context, transport Tra req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_invalidate.go b/esapi/api.xpack.security.saml_invalidate.go index 8172f702e3..3374f239dd 100644 --- a/esapi/api.xpack.security.saml_invalidate.go +++ b/esapi/api.xpack.security.saml_invalidate.go @@ -102,7 +102,7 @@ func (r SecuritySamlInvalidateRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_logout.go b/esapi/api.xpack.security.saml_logout.go index 2f4e3d0173..524f2afdb6 100644 --- a/esapi/api.xpack.security.saml_logout.go +++ b/esapi/api.xpack.security.saml_logout.go @@ -102,7 +102,7 @@ func (r SecuritySamlLogoutRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_prepare_authentication.go b/esapi/api.xpack.security.saml_prepare_authentication.go index 802e62e62e..4e31f609b9 100644 --- a/esapi/api.xpack.security.saml_prepare_authentication.go +++ b/esapi/api.xpack.security.saml_prepare_authentication.go @@ -102,7 +102,7 @@ func (r SecuritySamlPrepareAuthenticationRequest) Do(ctx context.Context, transp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.suggest_user_profiles.go b/esapi/api.xpack.security.suggest_user_profiles.go index 923ccb3811..4a5af34a26 100644 --- a/esapi/api.xpack.security.suggest_user_profiles.go +++ b/esapi/api.xpack.security.suggest_user_profiles.go @@ -110,7 +110,7 @@ func (r SecuritySuggestUserProfilesRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.update_api_key.go b/esapi/api.xpack.security.update_api_key.go index b312694246..d0694f2dce 100644 --- a/esapi/api.xpack.security.update_api_key.go +++ b/esapi/api.xpack.security.update_api_key.go @@ -109,7 +109,7 @@ func (r SecurityUpdateAPIKeyRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.update_user_profile_data.go b/esapi/api.xpack.security.update_user_profile_data.go index 39ff85e957..740c6ea1e7 100644 --- a/esapi/api.xpack.security.update_user_profile_data.go +++ b/esapi/api.xpack.security.update_user_profile_data.go @@ -130,7 +130,7 @@ func (r SecurityUpdateUserProfileDataRequest) Do(ctx context.Context, transport req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.slm.put_lifecycle.go b/esapi/api.xpack.slm.put_lifecycle.go index 55d78340d3..5649ceb3c9 100644 --- a/esapi/api.xpack.slm.put_lifecycle.go +++ b/esapi/api.xpack.slm.put_lifecycle.go @@ -109,7 +109,7 @@ func (r SlmPutLifecycleRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.sql.clear_cursor.go b/esapi/api.xpack.sql.clear_cursor.go index 4be7d1784c..6c929e06f1 100644 --- a/esapi/api.xpack.sql.clear_cursor.go +++ b/esapi/api.xpack.sql.clear_cursor.go @@ -102,7 +102,7 @@ func (r SQLClearCursorRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.sql.query.go b/esapi/api.xpack.sql.query.go index e297c37f1b..a5dee2f0e5 100644 --- a/esapi/api.xpack.sql.query.go +++ b/esapi/api.xpack.sql.query.go @@ -108,7 +108,7 @@ func (r SQLQueryRequest) Do(ctx context.Context, transport Transport) (*Response req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.sql.translate.go b/esapi/api.xpack.sql.translate.go index 0cb4e701a9..89d822b433 100644 --- a/esapi/api.xpack.sql.translate.go +++ b/esapi/api.xpack.sql.translate.go @@ -102,7 +102,7 @@ func (r SQLTranslateRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.text_structure.find_structure.go b/esapi/api.xpack.text_structure.find_structure.go index 1654c6a599..ca184b538a 100644 --- a/esapi/api.xpack.text_structure.find_structure.go +++ b/esapi/api.xpack.text_structure.find_structure.go @@ -175,7 +175,7 @@ func (r TextStructureFindStructureRequest) Do(ctx context.Context, transport Tra req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.transform.preview_transform.go b/esapi/api.xpack.transform.preview_transform.go index 7bdca56ed0..4f22362e29 100644 --- a/esapi/api.xpack.transform.preview_transform.go +++ b/esapi/api.xpack.transform.preview_transform.go @@ -118,7 +118,7 @@ func (r TransformPreviewTransformRequest) Do(ctx context.Context, transport Tran req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.transform.put_transform.go b/esapi/api.xpack.transform.put_transform.go index d47664e64f..24e55e22f1 100644 --- a/esapi/api.xpack.transform.put_transform.go +++ b/esapi/api.xpack.transform.put_transform.go @@ -120,7 +120,7 @@ func (r TransformPutTransformRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.transform.update_transform.go b/esapi/api.xpack.transform.update_transform.go index ac152e1488..c49af6cd63 100644 --- a/esapi/api.xpack.transform.update_transform.go +++ b/esapi/api.xpack.transform.update_transform.go @@ -122,7 +122,7 @@ func (r TransformUpdateTransformRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.watcher.execute_watch.go b/esapi/api.xpack.watcher.execute_watch.go index 6fb61bc03d..c6ab35000d 100644 --- a/esapi/api.xpack.watcher.execute_watch.go +++ b/esapi/api.xpack.watcher.execute_watch.go @@ -120,7 +120,7 @@ func (r WatcherExecuteWatchRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.watcher.put_watch.go b/esapi/api.xpack.watcher.put_watch.go index b147adad26..f755294d09 100644 --- a/esapi/api.xpack.watcher.put_watch.go +++ b/esapi/api.xpack.watcher.put_watch.go @@ -131,7 +131,7 @@ func (r WatcherPutWatchRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.watcher.query_watches.go b/esapi/api.xpack.watcher.query_watches.go index 2bda80680d..94ecd49be1 100644 --- a/esapi/api.xpack.watcher.query_watches.go +++ b/esapi/api.xpack.watcher.query_watches.go @@ -102,7 +102,7 @@ func (r WatcherQueryWatchesRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil { + if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/internal/build/cmd/generate/commands/gensource/generator.go b/internal/build/cmd/generate/commands/gensource/generator.go index 18055a401d..0d7c476ba2 100644 --- a/internal/build/cmd/generate/commands/gensource/generator.go +++ b/internal/build/cmd/generate/commands/gensource/generator.go @@ -826,7 +826,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context, }` + "\n\n") if g.Endpoint.Body != nil { - g.w(`if r.Body != nil { + g.w(`if r.Body != nil && req.Header.Get(headerContentType) == "" { req.Header[headerContentType] = headerContentTypeJSON }` + "\n\n") } From 65a496bbae53388bfc2c1654ad907b509b568951 Mon Sep 17 00:00:00 2001 From: pzl Date: Mon, 10 Oct 2022 10:28:36 -0400 Subject: [PATCH 2/4] undo generation --- esapi/api.bulk.go | 2 +- esapi/api.clear_scroll.go | 2 +- esapi/api.cluster.allocation_explain.go | 2 +- esapi/api.cluster.put_component_template.go | 2 +- esapi/api.cluster.put_settings.go | 2 +- esapi/api.cluster.reroute.go | 2 +- esapi/api.count.go | 2 +- esapi/api.create.go | 2 +- esapi/api.delete_by_query.go | 2 +- esapi/api.explain.go | 2 +- esapi/api.field_caps.go | 2 +- esapi/api.fleet.msearch.go | 2 +- esapi/api.fleet.search.go | 2 +- esapi/api.index.go | 2 +- esapi/api.indices.analyze.go | 2 +- esapi/api.indices.clone.go | 2 +- esapi/api.indices.create.go | 2 +- esapi/api.indices.modify_data_stream.go | 2 +- esapi/api.indices.put_alias.go | 2 +- esapi/api.indices.put_index_template.go | 2 +- esapi/api.indices.put_mapping.go | 2 +- esapi/api.indices.put_settings.go | 2 +- esapi/api.indices.put_template.go | 2 +- esapi/api.indices.rollover.go | 2 +- esapi/api.indices.shrink.go | 2 +- esapi/api.indices.simulate_index_template.go | 2 +- esapi/api.indices.simulate_template.go | 2 +- esapi/api.indices.split.go | 2 +- esapi/api.indices.update_aliases.go | 2 +- esapi/api.indices.validate_query.go | 2 +- esapi/api.ingest.put_pipeline.go | 2 +- esapi/api.ingest.simulate.go | 2 +- esapi/api.knn_search.go | 2 +- esapi/api.mget.go | 2 +- esapi/api.msearch.go | 2 +- esapi/api.msearch_template.go | 2 +- esapi/api.mtermvectors.go | 2 +- esapi/api.nodes.reload_secure_settings.go | 2 +- esapi/api.put_script.go | 2 +- esapi/api.rank_eval.go | 2 +- esapi/api.reindex.go | 2 +- esapi/api.render_search_template.go | 2 +- esapi/api.scripts_painless_execute.go | 2 +- esapi/api.scroll.go | 2 +- esapi/api.search.go | 2 +- esapi/api.search_mvt.go | 2 +- esapi/api.search_template.go | 2 +- esapi/api.shutdown.put_node.go | 2 +- esapi/api.snapshot.clone.go | 2 +- esapi/api.snapshot.create.go | 2 +- esapi/api.snapshot.create_repository.go | 2 +- esapi/api.snapshot.restore.go | 2 +- esapi/api.terms_enum.go | 2 +- esapi/api.termvectors.go | 2 +- esapi/api.update.go | 2 +- esapi/api.update_by_query.go | 2 +- esapi/api.xpack.async_search.submit.go | 2 +- esapi/api.xpack.autoscaling.put_autoscaling_policy.go | 2 +- esapi/api.xpack.ccr.follow.go | 2 +- esapi/api.xpack.ccr.forget_follower.go | 2 +- esapi/api.xpack.ccr.put_auto_follow_pattern.go | 2 +- esapi/api.xpack.ccr.resume_follow.go | 2 +- esapi/api.xpack.close_point_in_time.go | 2 +- esapi/api.xpack.enrich.put_policy.go | 2 +- esapi/api.xpack.eql.search.go | 2 +- esapi/api.xpack.graph.explore.go | 2 +- esapi/api.xpack.ilm.migrate_to_data_tiers.go | 2 +- esapi/api.xpack.ilm.move_to_step.go | 2 +- esapi/api.xpack.ilm.put_lifecycle.go | 2 +- esapi/api.xpack.license.post.go | 2 +- esapi/api.xpack.logstash.put_pipeline.go | 2 +- esapi/api.xpack.ml.close_job.go | 2 +- esapi/api.xpack.ml.delete_expired_data.go | 2 +- esapi/api.xpack.ml.estimate_model_memory.go | 2 +- esapi/api.xpack.ml.evaluate_data_frame.go | 2 +- esapi/api.xpack.ml.explain_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.flush_job.go | 2 +- esapi/api.xpack.ml.forecast.go | 2 +- esapi/api.xpack.ml.get_buckets.go | 2 +- esapi/api.xpack.ml.get_calendars.go | 2 +- esapi/api.xpack.ml.get_categories.go | 2 +- esapi/api.xpack.ml.get_influencers.go | 2 +- esapi/api.xpack.ml.get_model_snapshots.go | 2 +- esapi/api.xpack.ml.get_overall_buckets.go | 2 +- esapi/api.xpack.ml.get_records.go | 2 +- esapi/api.xpack.ml.infer_trained_model.go | 2 +- esapi/api.xpack.ml.open_job.go | 2 +- esapi/api.xpack.ml.post_calendar_events.go | 2 +- esapi/api.xpack.ml.post_data.go | 2 +- esapi/api.xpack.ml.preview_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.preview_datafeed.go | 2 +- esapi/api.xpack.ml.put_calendar.go | 2 +- esapi/api.xpack.ml.put_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.put_datafeed.go | 2 +- esapi/api.xpack.ml.put_filter.go | 2 +- esapi/api.xpack.ml.put_job.go | 2 +- esapi/api.xpack.ml.put_trained_model.go | 2 +- esapi/api.xpack.ml.put_trained_model_definition_part.go | 2 +- esapi/api.xpack.ml.put_trained_model_vocabulary.go | 2 +- esapi/api.xpack.ml.revert_model_snapshot.go | 2 +- esapi/api.xpack.ml.start_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.start_datafeed.go | 2 +- esapi/api.xpack.ml.stop_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.stop_datafeed.go | 2 +- esapi/api.xpack.ml.stop_trained_model_deployment.go | 2 +- esapi/api.xpack.ml.update_data_frame_analytics.go | 2 +- esapi/api.xpack.ml.update_datafeed.go | 2 +- esapi/api.xpack.ml.update_filter.go | 2 +- esapi/api.xpack.ml.update_job.go | 2 +- esapi/api.xpack.ml.update_model_snapshot.go | 2 +- esapi/api.xpack.ml.validate.go | 2 +- esapi/api.xpack.ml.validate_detector.go | 2 +- esapi/api.xpack.monitoring.bulk.go | 2 +- esapi/api.xpack.rollup.put_job.go | 2 +- esapi/api.xpack.rollup.rollup_search.go | 2 +- esapi/api.xpack.searchable_snapshots.mount.go | 2 +- esapi/api.xpack.security.activate_user_profile.go | 2 +- esapi/api.xpack.security.change_password.go | 2 +- esapi/api.xpack.security.create_api_key.go | 2 +- esapi/api.xpack.security.get_token.go | 2 +- esapi/api.xpack.security.grant_api_key.go | 2 +- esapi/api.xpack.security.has_privileges.go | 2 +- esapi/api.xpack.security.has_privileges_user_profile.go | 2 +- esapi/api.xpack.security.invalidate_api_key.go | 2 +- esapi/api.xpack.security.invalidate_token.go | 2 +- esapi/api.xpack.security.oidc_authenticate.go | 2 +- esapi/api.xpack.security.oidc_logout.go | 2 +- esapi/api.xpack.security.oidc_prepare_authentication.go | 2 +- esapi/api.xpack.security.put_privileges.go | 2 +- esapi/api.xpack.security.put_role.go | 2 +- esapi/api.xpack.security.put_role_mapping.go | 2 +- esapi/api.xpack.security.put_user.go | 2 +- esapi/api.xpack.security.query_api_keys.go | 2 +- esapi/api.xpack.security.saml_authenticate.go | 2 +- esapi/api.xpack.security.saml_complete_logout.go | 2 +- esapi/api.xpack.security.saml_invalidate.go | 2 +- esapi/api.xpack.security.saml_logout.go | 2 +- esapi/api.xpack.security.saml_prepare_authentication.go | 2 +- esapi/api.xpack.security.suggest_user_profiles.go | 2 +- esapi/api.xpack.security.update_api_key.go | 2 +- esapi/api.xpack.security.update_user_profile_data.go | 2 +- esapi/api.xpack.slm.put_lifecycle.go | 2 +- esapi/api.xpack.sql.clear_cursor.go | 2 +- esapi/api.xpack.sql.query.go | 2 +- esapi/api.xpack.sql.translate.go | 2 +- esapi/api.xpack.text_structure.find_structure.go | 2 +- esapi/api.xpack.transform.preview_transform.go | 2 +- esapi/api.xpack.transform.put_transform.go | 2 +- esapi/api.xpack.transform.update_transform.go | 2 +- esapi/api.xpack.watcher.execute_watch.go | 2 +- esapi/api.xpack.watcher.put_watch.go | 2 +- esapi/api.xpack.watcher.query_watches.go | 2 +- 152 files changed, 152 insertions(+), 152 deletions(-) diff --git a/esapi/api.bulk.go b/esapi/api.bulk.go index c2084310cb..edab153b46 100644 --- a/esapi/api.bulk.go +++ b/esapi/api.bulk.go @@ -162,7 +162,7 @@ func (r BulkRequest) Do(ctx context.Context, transport Transport) (*Response, er req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.clear_scroll.go b/esapi/api.clear_scroll.go index 533e5d3a62..128f33fcca 100644 --- a/esapi/api.clear_scroll.go +++ b/esapi/api.clear_scroll.go @@ -111,7 +111,7 @@ func (r ClearScrollRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.allocation_explain.go b/esapi/api.cluster.allocation_explain.go index aa7465a05b..d429898248 100644 --- a/esapi/api.cluster.allocation_explain.go +++ b/esapi/api.cluster.allocation_explain.go @@ -114,7 +114,7 @@ func (r ClusterAllocationExplainRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.put_component_template.go b/esapi/api.cluster.put_component_template.go index eea24bb66b..b99d70023a 100644 --- a/esapi/api.cluster.put_component_template.go +++ b/esapi/api.cluster.put_component_template.go @@ -125,7 +125,7 @@ func (r ClusterPutComponentTemplateRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.put_settings.go b/esapi/api.cluster.put_settings.go index cb0b6cfc22..3e18f662af 100644 --- a/esapi/api.cluster.put_settings.go +++ b/esapi/api.cluster.put_settings.go @@ -120,7 +120,7 @@ func (r ClusterPutSettingsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.cluster.reroute.go b/esapi/api.cluster.reroute.go index 3c1fa3d559..8987c51458 100644 --- a/esapi/api.cluster.reroute.go +++ b/esapi/api.cluster.reroute.go @@ -135,7 +135,7 @@ func (r ClusterRerouteRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.count.go b/esapi/api.count.go index 38fd2ed589..b92edaeb38 100644 --- a/esapi/api.count.go +++ b/esapi/api.count.go @@ -181,7 +181,7 @@ func (r CountRequest) Do(ctx context.Context, transport Transport) (*Response, e req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.create.go b/esapi/api.create.go index 45097e7199..6dee17e5a0 100644 --- a/esapi/api.create.go +++ b/esapi/api.create.go @@ -150,7 +150,7 @@ func (r CreateRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.delete_by_query.go b/esapi/api.delete_by_query.go index 4fa3f90a9f..b75ebda9ff 100644 --- a/esapi/api.delete_by_query.go +++ b/esapi/api.delete_by_query.go @@ -261,7 +261,7 @@ func (r DeleteByQueryRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.explain.go b/esapi/api.explain.go index 3381f482c0..82127ae82d 100644 --- a/esapi/api.explain.go +++ b/esapi/api.explain.go @@ -172,7 +172,7 @@ func (r ExplainRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.field_caps.go b/esapi/api.field_caps.go index 470c9fb3cb..6b44812ca4 100644 --- a/esapi/api.field_caps.go +++ b/esapi/api.field_caps.go @@ -146,7 +146,7 @@ func (r FieldCapsRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.fleet.msearch.go b/esapi/api.fleet.msearch.go index c6a859b13b..7515bf5128 100644 --- a/esapi/api.fleet.msearch.go +++ b/esapi/api.fleet.msearch.go @@ -111,7 +111,7 @@ func (r FleetMsearchRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.fleet.search.go b/esapi/api.fleet.search.go index 6b1a2f1986..10339f427f 100644 --- a/esapi/api.fleet.search.go +++ b/esapi/api.fleet.search.go @@ -127,7 +127,7 @@ func (r FleetSearchRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.index.go b/esapi/api.index.go index 784dd15926..6fbf93af35 100644 --- a/esapi/api.index.go +++ b/esapi/api.index.go @@ -174,7 +174,7 @@ func (r IndexRequest) Do(ctx context.Context, transport Transport) (*Response, e req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.analyze.go b/esapi/api.indices.analyze.go index 449fc0aa37..a3fd408e69 100644 --- a/esapi/api.indices.analyze.go +++ b/esapi/api.indices.analyze.go @@ -113,7 +113,7 @@ func (r IndicesAnalyzeRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.clone.go b/esapi/api.indices.clone.go index bd86ddf7ee..997927a0a1 100644 --- a/esapi/api.indices.clone.go +++ b/esapi/api.indices.clone.go @@ -128,7 +128,7 @@ func (r IndicesCloneRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.create.go b/esapi/api.indices.create.go index a0b568327d..1e4367d756 100644 --- a/esapi/api.indices.create.go +++ b/esapi/api.indices.create.go @@ -122,7 +122,7 @@ func (r IndicesCreateRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.modify_data_stream.go b/esapi/api.indices.modify_data_stream.go index 0213250bbe..8822a8bcea 100644 --- a/esapi/api.indices.modify_data_stream.go +++ b/esapi/api.indices.modify_data_stream.go @@ -102,7 +102,7 @@ func (r IndicesModifyDataStreamRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_alias.go b/esapi/api.indices.put_alias.go index 2f761ff620..b609ab7f69 100644 --- a/esapi/api.indices.put_alias.go +++ b/esapi/api.indices.put_alias.go @@ -128,7 +128,7 @@ func (r IndicesPutAliasRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_index_template.go b/esapi/api.indices.put_index_template.go index cb2fb61c64..ff8d906bd5 100644 --- a/esapi/api.indices.put_index_template.go +++ b/esapi/api.indices.put_index_template.go @@ -125,7 +125,7 @@ func (r IndicesPutIndexTemplateRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_mapping.go b/esapi/api.indices.put_mapping.go index 8d136fc268..7763ce051a 100644 --- a/esapi/api.indices.put_mapping.go +++ b/esapi/api.indices.put_mapping.go @@ -141,7 +141,7 @@ func (r IndicesPutMappingRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_settings.go b/esapi/api.indices.put_settings.go index 8a7e702462..f28e3c5f4f 100644 --- a/esapi/api.indices.put_settings.go +++ b/esapi/api.indices.put_settings.go @@ -147,7 +147,7 @@ func (r IndicesPutSettingsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.put_template.go b/esapi/api.indices.put_template.go index 4fce917394..eaaffe8581 100644 --- a/esapi/api.indices.put_template.go +++ b/esapi/api.indices.put_template.go @@ -125,7 +125,7 @@ func (r IndicesPutTemplateRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.rollover.go b/esapi/api.indices.rollover.go index c80667d927..685b353c5e 100644 --- a/esapi/api.indices.rollover.go +++ b/esapi/api.indices.rollover.go @@ -136,7 +136,7 @@ func (r IndicesRolloverRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.shrink.go b/esapi/api.indices.shrink.go index 8823d588f6..070db1b5e1 100644 --- a/esapi/api.indices.shrink.go +++ b/esapi/api.indices.shrink.go @@ -128,7 +128,7 @@ func (r IndicesShrinkRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.simulate_index_template.go b/esapi/api.indices.simulate_index_template.go index 4aa5e84dfc..47a9abf251 100644 --- a/esapi/api.indices.simulate_index_template.go +++ b/esapi/api.indices.simulate_index_template.go @@ -127,7 +127,7 @@ func (r IndicesSimulateIndexTemplateRequest) Do(ctx context.Context, transport T req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.simulate_template.go b/esapi/api.indices.simulate_template.go index 45343eb09b..16f6ff73d3 100644 --- a/esapi/api.indices.simulate_template.go +++ b/esapi/api.indices.simulate_template.go @@ -129,7 +129,7 @@ func (r IndicesSimulateTemplateRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.split.go b/esapi/api.indices.split.go index 673cc6aae9..8149c37835 100644 --- a/esapi/api.indices.split.go +++ b/esapi/api.indices.split.go @@ -128,7 +128,7 @@ func (r IndicesSplitRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.update_aliases.go b/esapi/api.indices.update_aliases.go index ed7a061983..bc98409403 100644 --- a/esapi/api.indices.update_aliases.go +++ b/esapi/api.indices.update_aliases.go @@ -114,7 +114,7 @@ func (r IndicesUpdateAliasesRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.indices.validate_query.go b/esapi/api.indices.validate_query.go index ac70c8178f..3c1a011769 100644 --- a/esapi/api.indices.validate_query.go +++ b/esapi/api.indices.validate_query.go @@ -173,7 +173,7 @@ func (r IndicesValidateQueryRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.ingest.put_pipeline.go b/esapi/api.ingest.put_pipeline.go index 1aa363da20..cf099d1b84 100644 --- a/esapi/api.ingest.put_pipeline.go +++ b/esapi/api.ingest.put_pipeline.go @@ -127,7 +127,7 @@ func (r IngestPutPipelineRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.ingest.simulate.go b/esapi/api.ingest.simulate.go index 4315ea9297..6bdf657b77 100644 --- a/esapi/api.ingest.simulate.go +++ b/esapi/api.ingest.simulate.go @@ -120,7 +120,7 @@ func (r IngestSimulateRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.knn_search.go b/esapi/api.knn_search.go index 39ee3a22aa..8d07754f4d 100644 --- a/esapi/api.knn_search.go +++ b/esapi/api.knn_search.go @@ -120,7 +120,7 @@ func (r KnnSearchRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.mget.go b/esapi/api.mget.go index f2d1c8fa69..c7ba04630d 100644 --- a/esapi/api.mget.go +++ b/esapi/api.mget.go @@ -156,7 +156,7 @@ func (r MgetRequest) Do(ctx context.Context, transport Transport) (*Response, er req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.msearch.go b/esapi/api.msearch.go index 4b29a4762a..7edc214683 100644 --- a/esapi/api.msearch.go +++ b/esapi/api.msearch.go @@ -146,7 +146,7 @@ func (r MsearchRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.msearch_template.go b/esapi/api.msearch_template.go index 8c1fc62dab..4fa470f409 100644 --- a/esapi/api.msearch_template.go +++ b/esapi/api.msearch_template.go @@ -138,7 +138,7 @@ func (r MsearchTemplateRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.mtermvectors.go b/esapi/api.mtermvectors.go index 12f450ef81..88bc3becf4 100644 --- a/esapi/api.mtermvectors.go +++ b/esapi/api.mtermvectors.go @@ -171,7 +171,7 @@ func (r MtermvectorsRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.nodes.reload_secure_settings.go b/esapi/api.nodes.reload_secure_settings.go index 4dee4e121c..57236c2313 100644 --- a/esapi/api.nodes.reload_secure_settings.go +++ b/esapi/api.nodes.reload_secure_settings.go @@ -118,7 +118,7 @@ func (r NodesReloadSecureSettingsRequest) Do(ctx context.Context, transport Tran req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.put_script.go b/esapi/api.put_script.go index 264cd7b128..7a2d51655e 100644 --- a/esapi/api.put_script.go +++ b/esapi/api.put_script.go @@ -129,7 +129,7 @@ func (r PutScriptRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.rank_eval.go b/esapi/api.rank_eval.go index 02266e6505..808bf3365e 100644 --- a/esapi/api.rank_eval.go +++ b/esapi/api.rank_eval.go @@ -131,7 +131,7 @@ func (r RankEvalRequest) Do(ctx context.Context, transport Transport) (*Response req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.reindex.go b/esapi/api.reindex.go index 3a181f1cfd..4da9717786 100644 --- a/esapi/api.reindex.go +++ b/esapi/api.reindex.go @@ -148,7 +148,7 @@ func (r ReindexRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.render_search_template.go b/esapi/api.render_search_template.go index d300a54d07..3e580bfae7 100644 --- a/esapi/api.render_search_template.go +++ b/esapi/api.render_search_template.go @@ -111,7 +111,7 @@ func (r RenderSearchTemplateRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.scripts_painless_execute.go b/esapi/api.scripts_painless_execute.go index 029ef17d78..b79cc7e45f 100644 --- a/esapi/api.scripts_painless_execute.go +++ b/esapi/api.scripts_painless_execute.go @@ -104,7 +104,7 @@ func (r ScriptsPainlessExecuteRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.scroll.go b/esapi/api.scroll.go index be7c8eaa28..999f99ede8 100644 --- a/esapi/api.scroll.go +++ b/esapi/api.scroll.go @@ -120,7 +120,7 @@ func (r ScrollRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.search.go b/esapi/api.search.go index 859a9e7346..80e0a4565b 100644 --- a/esapi/api.search.go +++ b/esapi/api.search.go @@ -333,7 +333,7 @@ func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.search_mvt.go b/esapi/api.search_mvt.go index aca255f464..553c3f2888 100644 --- a/esapi/api.search_mvt.go +++ b/esapi/api.search_mvt.go @@ -174,7 +174,7 @@ func (r SearchMvtRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.search_template.go b/esapi/api.search_template.go index 3fe83ce1fb..4edd21acaf 100644 --- a/esapi/api.search_template.go +++ b/esapi/api.search_template.go @@ -179,7 +179,7 @@ func (r SearchTemplateRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.shutdown.put_node.go b/esapi/api.shutdown.put_node.go index eaa3a8a6c5..fcc5d71797 100644 --- a/esapi/api.shutdown.put_node.go +++ b/esapi/api.shutdown.put_node.go @@ -109,7 +109,7 @@ func (r ShutdownPutNodeRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.clone.go b/esapi/api.snapshot.clone.go index 6ea0a97542..b2e93dae6a 100644 --- a/esapi/api.snapshot.clone.go +++ b/esapi/api.snapshot.clone.go @@ -122,7 +122,7 @@ func (r SnapshotCloneRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.create.go b/esapi/api.snapshot.create.go index d4f24ca6e0..61d96bf89a 100644 --- a/esapi/api.snapshot.create.go +++ b/esapi/api.snapshot.create.go @@ -123,7 +123,7 @@ func (r SnapshotCreateRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.create_repository.go b/esapi/api.snapshot.create_repository.go index 1cceeb1c5d..a2a9ac3002 100644 --- a/esapi/api.snapshot.create_repository.go +++ b/esapi/api.snapshot.create_repository.go @@ -125,7 +125,7 @@ func (r SnapshotCreateRepositoryRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.snapshot.restore.go b/esapi/api.snapshot.restore.go index 2b04e6b3db..a5bb412b10 100644 --- a/esapi/api.snapshot.restore.go +++ b/esapi/api.snapshot.restore.go @@ -125,7 +125,7 @@ func (r SnapshotRestoreRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.terms_enum.go b/esapi/api.terms_enum.go index f028368190..6393d6a32f 100644 --- a/esapi/api.terms_enum.go +++ b/esapi/api.terms_enum.go @@ -112,7 +112,7 @@ func (r TermsEnumRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.termvectors.go b/esapi/api.termvectors.go index d0f95f6cd9..d7504160a5 100644 --- a/esapi/api.termvectors.go +++ b/esapi/api.termvectors.go @@ -169,7 +169,7 @@ func (r TermvectorsRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.update.go b/esapi/api.update.go index 69176eff36..950f12d7f5 100644 --- a/esapi/api.update.go +++ b/esapi/api.update.go @@ -173,7 +173,7 @@ func (r UpdateRequest) Do(ctx context.Context, transport Transport) (*Response, req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.update_by_query.go b/esapi/api.update_by_query.go index 185075933f..46836f6b15 100644 --- a/esapi/api.update_by_query.go +++ b/esapi/api.update_by_query.go @@ -272,7 +272,7 @@ func (r UpdateByQueryRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.async_search.submit.go b/esapi/api.xpack.async_search.submit.go index e777762fd4..4cb869f586 100644 --- a/esapi/api.xpack.async_search.submit.go +++ b/esapi/api.xpack.async_search.submit.go @@ -318,7 +318,7 @@ func (r AsyncSearchSubmitRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.autoscaling.put_autoscaling_policy.go b/esapi/api.xpack.autoscaling.put_autoscaling_policy.go index 129ec7abf4..bd47be8c04 100644 --- a/esapi/api.xpack.autoscaling.put_autoscaling_policy.go +++ b/esapi/api.xpack.autoscaling.put_autoscaling_policy.go @@ -109,7 +109,7 @@ func (r AutoscalingPutAutoscalingPolicyRequest) Do(ctx context.Context, transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.follow.go b/esapi/api.xpack.ccr.follow.go index 61896d2aa8..69a97ebc5c 100644 --- a/esapi/api.xpack.ccr.follow.go +++ b/esapi/api.xpack.ccr.follow.go @@ -115,7 +115,7 @@ func (r CCRFollowRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.forget_follower.go b/esapi/api.xpack.ccr.forget_follower.go index caebf9a218..518bdbdcd2 100644 --- a/esapi/api.xpack.ccr.forget_follower.go +++ b/esapi/api.xpack.ccr.forget_follower.go @@ -109,7 +109,7 @@ func (r CCRForgetFollowerRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.put_auto_follow_pattern.go b/esapi/api.xpack.ccr.put_auto_follow_pattern.go index fcb6c05ce4..6011c2c44e 100644 --- a/esapi/api.xpack.ccr.put_auto_follow_pattern.go +++ b/esapi/api.xpack.ccr.put_auto_follow_pattern.go @@ -109,7 +109,7 @@ func (r CCRPutAutoFollowPatternRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ccr.resume_follow.go b/esapi/api.xpack.ccr.resume_follow.go index f0416d2cdc..810236f654 100644 --- a/esapi/api.xpack.ccr.resume_follow.go +++ b/esapi/api.xpack.ccr.resume_follow.go @@ -109,7 +109,7 @@ func (r CCRResumeFollowRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.close_point_in_time.go b/esapi/api.xpack.close_point_in_time.go index f31ac5602e..6b85f9a8ce 100644 --- a/esapi/api.xpack.close_point_in_time.go +++ b/esapi/api.xpack.close_point_in_time.go @@ -102,7 +102,7 @@ func (r ClosePointInTimeRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.enrich.put_policy.go b/esapi/api.xpack.enrich.put_policy.go index c4a65b8059..88d2d54703 100644 --- a/esapi/api.xpack.enrich.put_policy.go +++ b/esapi/api.xpack.enrich.put_policy.go @@ -109,7 +109,7 @@ func (r EnrichPutPolicyRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.eql.search.go b/esapi/api.xpack.eql.search.go index 07acd7dd15..3e1ea48a42 100644 --- a/esapi/api.xpack.eql.search.go +++ b/esapi/api.xpack.eql.search.go @@ -127,7 +127,7 @@ func (r EqlSearchRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.graph.explore.go b/esapi/api.xpack.graph.explore.go index 1db48f4b20..d9a5ffa115 100644 --- a/esapi/api.xpack.graph.explore.go +++ b/esapi/api.xpack.graph.explore.go @@ -126,7 +126,7 @@ func (r GraphExploreRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ilm.migrate_to_data_tiers.go b/esapi/api.xpack.ilm.migrate_to_data_tiers.go index fac5b03613..a77c4e411f 100644 --- a/esapi/api.xpack.ilm.migrate_to_data_tiers.go +++ b/esapi/api.xpack.ilm.migrate_to_data_tiers.go @@ -109,7 +109,7 @@ func (r ILMMigrateToDataTiersRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ilm.move_to_step.go b/esapi/api.xpack.ilm.move_to_step.go index f28e8aac3f..6f92760027 100644 --- a/esapi/api.xpack.ilm.move_to_step.go +++ b/esapi/api.xpack.ilm.move_to_step.go @@ -109,7 +109,7 @@ func (r ILMMoveToStepRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ilm.put_lifecycle.go b/esapi/api.xpack.ilm.put_lifecycle.go index a67756f022..4907e3df62 100644 --- a/esapi/api.xpack.ilm.put_lifecycle.go +++ b/esapi/api.xpack.ilm.put_lifecycle.go @@ -109,7 +109,7 @@ func (r ILMPutLifecycleRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.license.post.go b/esapi/api.xpack.license.post.go index 0b0c0f57f3..88e9eecfe6 100644 --- a/esapi/api.xpack.license.post.go +++ b/esapi/api.xpack.license.post.go @@ -109,7 +109,7 @@ func (r LicensePostRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.logstash.put_pipeline.go b/esapi/api.xpack.logstash.put_pipeline.go index 562e2f6fae..b60a16ee9e 100644 --- a/esapi/api.xpack.logstash.put_pipeline.go +++ b/esapi/api.xpack.logstash.put_pipeline.go @@ -109,7 +109,7 @@ func (r LogstashPutPipelineRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.close_job.go b/esapi/api.xpack.ml.close_job.go index a0d199cbe3..fe8bcb793d 100644 --- a/esapi/api.xpack.ml.close_job.go +++ b/esapi/api.xpack.ml.close_job.go @@ -129,7 +129,7 @@ func (r MLCloseJobRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.delete_expired_data.go b/esapi/api.xpack.ml.delete_expired_data.go index 1295653052..9fedad9861 100644 --- a/esapi/api.xpack.ml.delete_expired_data.go +++ b/esapi/api.xpack.ml.delete_expired_data.go @@ -124,7 +124,7 @@ func (r MLDeleteExpiredDataRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.estimate_model_memory.go b/esapi/api.xpack.ml.estimate_model_memory.go index dac6d256ca..2970adf240 100644 --- a/esapi/api.xpack.ml.estimate_model_memory.go +++ b/esapi/api.xpack.ml.estimate_model_memory.go @@ -102,7 +102,7 @@ func (r MLEstimateModelMemoryRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.evaluate_data_frame.go b/esapi/api.xpack.ml.evaluate_data_frame.go index 9fec7263ef..2b73050321 100644 --- a/esapi/api.xpack.ml.evaluate_data_frame.go +++ b/esapi/api.xpack.ml.evaluate_data_frame.go @@ -102,7 +102,7 @@ func (r MLEvaluateDataFrameRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.explain_data_frame_analytics.go b/esapi/api.xpack.ml.explain_data_frame_analytics.go index a07577d270..beedad544b 100644 --- a/esapi/api.xpack.ml.explain_data_frame_analytics.go +++ b/esapi/api.xpack.ml.explain_data_frame_analytics.go @@ -115,7 +115,7 @@ func (r MLExplainDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.flush_job.go b/esapi/api.xpack.ml.flush_job.go index 7067defce4..010d944000 100644 --- a/esapi/api.xpack.ml.flush_job.go +++ b/esapi/api.xpack.ml.flush_job.go @@ -138,7 +138,7 @@ func (r MLFlushJobRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.forecast.go b/esapi/api.xpack.ml.forecast.go index 4141efada1..8eb54fb74b 100644 --- a/esapi/api.xpack.ml.forecast.go +++ b/esapi/api.xpack.ml.forecast.go @@ -128,7 +128,7 @@ func (r MLForecastRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_buckets.go b/esapi/api.xpack.ml.get_buckets.go index 8b9fd97b44..79f9dff47c 100644 --- a/esapi/api.xpack.ml.get_buckets.go +++ b/esapi/api.xpack.ml.get_buckets.go @@ -166,7 +166,7 @@ func (r MLGetBucketsRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_calendars.go b/esapi/api.xpack.ml.get_calendars.go index 6a67e60034..f081f11f9b 100644 --- a/esapi/api.xpack.ml.get_calendars.go +++ b/esapi/api.xpack.ml.get_calendars.go @@ -123,7 +123,7 @@ func (r MLGetCalendarsRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_categories.go b/esapi/api.xpack.ml.get_categories.go index b9d967d5c0..be1863924a 100644 --- a/esapi/api.xpack.ml.get_categories.go +++ b/esapi/api.xpack.ml.get_categories.go @@ -137,7 +137,7 @@ func (r MLGetCategoriesRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_influencers.go b/esapi/api.xpack.ml.get_influencers.go index 6554636f8b..3842b29fde 100644 --- a/esapi/api.xpack.ml.get_influencers.go +++ b/esapi/api.xpack.ml.get_influencers.go @@ -156,7 +156,7 @@ func (r MLGetInfluencersRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_model_snapshots.go b/esapi/api.xpack.ml.get_model_snapshots.go index 6d504ef7b8..6a9d1f8081 100644 --- a/esapi/api.xpack.ml.get_model_snapshots.go +++ b/esapi/api.xpack.ml.get_model_snapshots.go @@ -149,7 +149,7 @@ func (r MLGetModelSnapshotsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_overall_buckets.go b/esapi/api.xpack.ml.get_overall_buckets.go index 053754ddb5..84c6fc3d1d 100644 --- a/esapi/api.xpack.ml.get_overall_buckets.go +++ b/esapi/api.xpack.ml.get_overall_buckets.go @@ -151,7 +151,7 @@ func (r MLGetOverallBucketsRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.get_records.go b/esapi/api.xpack.ml.get_records.go index 7def93e246..4949d6fe06 100644 --- a/esapi/api.xpack.ml.get_records.go +++ b/esapi/api.xpack.ml.get_records.go @@ -156,7 +156,7 @@ func (r MLGetRecordsRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.infer_trained_model.go b/esapi/api.xpack.ml.infer_trained_model.go index b5886a591e..456fee512c 100644 --- a/esapi/api.xpack.ml.infer_trained_model.go +++ b/esapi/api.xpack.ml.infer_trained_model.go @@ -122,7 +122,7 @@ func (r MLInferTrainedModelRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.open_job.go b/esapi/api.xpack.ml.open_job.go index b17bc93039..cd12915f94 100644 --- a/esapi/api.xpack.ml.open_job.go +++ b/esapi/api.xpack.ml.open_job.go @@ -111,7 +111,7 @@ func (r MLOpenJobRequest) Do(ctx context.Context, transport Transport) (*Respons req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.post_calendar_events.go b/esapi/api.xpack.ml.post_calendar_events.go index 2c51a1601f..f51fed7a8b 100644 --- a/esapi/api.xpack.ml.post_calendar_events.go +++ b/esapi/api.xpack.ml.post_calendar_events.go @@ -111,7 +111,7 @@ func (r MLPostCalendarEventsRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.post_data.go b/esapi/api.xpack.ml.post_data.go index ab0c464317..09e862ac2d 100644 --- a/esapi/api.xpack.ml.post_data.go +++ b/esapi/api.xpack.ml.post_data.go @@ -122,7 +122,7 @@ func (r MLPostDataRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.preview_data_frame_analytics.go b/esapi/api.xpack.ml.preview_data_frame_analytics.go index f9f265d0b5..a597ba805a 100644 --- a/esapi/api.xpack.ml.preview_data_frame_analytics.go +++ b/esapi/api.xpack.ml.preview_data_frame_analytics.go @@ -115,7 +115,7 @@ func (r MLPreviewDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.preview_datafeed.go b/esapi/api.xpack.ml.preview_datafeed.go index bdee6f2843..194d6f910a 100644 --- a/esapi/api.xpack.ml.preview_datafeed.go +++ b/esapi/api.xpack.ml.preview_datafeed.go @@ -124,7 +124,7 @@ func (r MLPreviewDatafeedRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_calendar.go b/esapi/api.xpack.ml.put_calendar.go index 283c0ff5ae..9ff498cc33 100644 --- a/esapi/api.xpack.ml.put_calendar.go +++ b/esapi/api.xpack.ml.put_calendar.go @@ -109,7 +109,7 @@ func (r MLPutCalendarRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_data_frame_analytics.go b/esapi/api.xpack.ml.put_data_frame_analytics.go index cf4a062f1b..29eaceee8d 100644 --- a/esapi/api.xpack.ml.put_data_frame_analytics.go +++ b/esapi/api.xpack.ml.put_data_frame_analytics.go @@ -111,7 +111,7 @@ func (r MLPutDataFrameAnalyticsRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_datafeed.go b/esapi/api.xpack.ml.put_datafeed.go index f43dd5fad1..96233c52dc 100644 --- a/esapi/api.xpack.ml.put_datafeed.go +++ b/esapi/api.xpack.ml.put_datafeed.go @@ -131,7 +131,7 @@ func (r MLPutDatafeedRequest) Do(ctx context.Context, transport Transport) (*Res req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_filter.go b/esapi/api.xpack.ml.put_filter.go index baf64c64ab..24206bc692 100644 --- a/esapi/api.xpack.ml.put_filter.go +++ b/esapi/api.xpack.ml.put_filter.go @@ -109,7 +109,7 @@ func (r MLPutFilterRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_job.go b/esapi/api.xpack.ml.put_job.go index 437b8691c3..5c88ddcb4a 100644 --- a/esapi/api.xpack.ml.put_job.go +++ b/esapi/api.xpack.ml.put_job.go @@ -131,7 +131,7 @@ func (r MLPutJobRequest) Do(ctx context.Context, transport Transport) (*Response req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_trained_model.go b/esapi/api.xpack.ml.put_trained_model.go index 2eee7c749c..2bdd61dede 100644 --- a/esapi/api.xpack.ml.put_trained_model.go +++ b/esapi/api.xpack.ml.put_trained_model.go @@ -116,7 +116,7 @@ func (r MLPutTrainedModelRequest) Do(ctx context.Context, transport Transport) ( req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_trained_model_definition_part.go b/esapi/api.xpack.ml.put_trained_model_definition_part.go index d6789f768f..84d8faebd5 100644 --- a/esapi/api.xpack.ml.put_trained_model_definition_part.go +++ b/esapi/api.xpack.ml.put_trained_model_definition_part.go @@ -122,7 +122,7 @@ func (r MLPutTrainedModelDefinitionPartRequest) Do(ctx context.Context, transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.put_trained_model_vocabulary.go b/esapi/api.xpack.ml.put_trained_model_vocabulary.go index a7efd4a916..3fa31573c4 100644 --- a/esapi/api.xpack.ml.put_trained_model_vocabulary.go +++ b/esapi/api.xpack.ml.put_trained_model_vocabulary.go @@ -113,7 +113,7 @@ func (r MLPutTrainedModelVocabularyRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.revert_model_snapshot.go b/esapi/api.xpack.ml.revert_model_snapshot.go index 851d491c05..3d933d5051 100644 --- a/esapi/api.xpack.ml.revert_model_snapshot.go +++ b/esapi/api.xpack.ml.revert_model_snapshot.go @@ -123,7 +123,7 @@ func (r MLRevertModelSnapshotRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.start_data_frame_analytics.go b/esapi/api.xpack.ml.start_data_frame_analytics.go index ab77ba1409..b5e356ddd2 100644 --- a/esapi/api.xpack.ml.start_data_frame_analytics.go +++ b/esapi/api.xpack.ml.start_data_frame_analytics.go @@ -120,7 +120,7 @@ func (r MLStartDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tran req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.start_datafeed.go b/esapi/api.xpack.ml.start_datafeed.go index 1e8c32affc..9b993770ad 100644 --- a/esapi/api.xpack.ml.start_datafeed.go +++ b/esapi/api.xpack.ml.start_datafeed.go @@ -128,7 +128,7 @@ func (r MLStartDatafeedRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.stop_data_frame_analytics.go b/esapi/api.xpack.ml.stop_data_frame_analytics.go index c71f213015..42208b0c3c 100644 --- a/esapi/api.xpack.ml.stop_data_frame_analytics.go +++ b/esapi/api.xpack.ml.stop_data_frame_analytics.go @@ -131,7 +131,7 @@ func (r MLStopDataFrameAnalyticsRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.stop_datafeed.go b/esapi/api.xpack.ml.stop_datafeed.go index 58401b5ed5..f2dc98929b 100644 --- a/esapi/api.xpack.ml.stop_datafeed.go +++ b/esapi/api.xpack.ml.stop_datafeed.go @@ -134,7 +134,7 @@ func (r MLStopDatafeedRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.stop_trained_model_deployment.go b/esapi/api.xpack.ml.stop_trained_model_deployment.go index 0cb48d63f5..764232763f 100644 --- a/esapi/api.xpack.ml.stop_trained_model_deployment.go +++ b/esapi/api.xpack.ml.stop_trained_model_deployment.go @@ -127,7 +127,7 @@ func (r MLStopTrainedModelDeploymentRequest) Do(ctx context.Context, transport T req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_data_frame_analytics.go b/esapi/api.xpack.ml.update_data_frame_analytics.go index f7ef050b6b..dfe43c6bb4 100644 --- a/esapi/api.xpack.ml.update_data_frame_analytics.go +++ b/esapi/api.xpack.ml.update_data_frame_analytics.go @@ -113,7 +113,7 @@ func (r MLUpdateDataFrameAnalyticsRequest) Do(ctx context.Context, transport Tra req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_datafeed.go b/esapi/api.xpack.ml.update_datafeed.go index f2ce2fc745..510e0a37fa 100644 --- a/esapi/api.xpack.ml.update_datafeed.go +++ b/esapi/api.xpack.ml.update_datafeed.go @@ -133,7 +133,7 @@ func (r MLUpdateDatafeedRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_filter.go b/esapi/api.xpack.ml.update_filter.go index b20105018e..983d793203 100644 --- a/esapi/api.xpack.ml.update_filter.go +++ b/esapi/api.xpack.ml.update_filter.go @@ -111,7 +111,7 @@ func (r MLUpdateFilterRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_job.go b/esapi/api.xpack.ml.update_job.go index bc871b37bf..ae23d6621b 100644 --- a/esapi/api.xpack.ml.update_job.go +++ b/esapi/api.xpack.ml.update_job.go @@ -111,7 +111,7 @@ func (r MLUpdateJobRequest) Do(ctx context.Context, transport Transport) (*Respo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.update_model_snapshot.go b/esapi/api.xpack.ml.update_model_snapshot.go index 9aa025527b..2cc4b94594 100644 --- a/esapi/api.xpack.ml.update_model_snapshot.go +++ b/esapi/api.xpack.ml.update_model_snapshot.go @@ -116,7 +116,7 @@ func (r MLUpdateModelSnapshotRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.validate.go b/esapi/api.xpack.ml.validate.go index 9fb5037ce0..4520696df2 100644 --- a/esapi/api.xpack.ml.validate.go +++ b/esapi/api.xpack.ml.validate.go @@ -102,7 +102,7 @@ func (r MLValidateRequest) Do(ctx context.Context, transport Transport) (*Respon req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.ml.validate_detector.go b/esapi/api.xpack.ml.validate_detector.go index eddbdc742d..3bc77ed7c5 100644 --- a/esapi/api.xpack.ml.validate_detector.go +++ b/esapi/api.xpack.ml.validate_detector.go @@ -102,7 +102,7 @@ func (r MLValidateDetectorRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.monitoring.bulk.go b/esapi/api.xpack.monitoring.bulk.go index 5094b49284..feb4bd6171 100644 --- a/esapi/api.xpack.monitoring.bulk.go +++ b/esapi/api.xpack.monitoring.bulk.go @@ -127,7 +127,7 @@ func (r MonitoringBulkRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.rollup.put_job.go b/esapi/api.xpack.rollup.put_job.go index 7d6fb060a5..6777bab03c 100644 --- a/esapi/api.xpack.rollup.put_job.go +++ b/esapi/api.xpack.rollup.put_job.go @@ -111,7 +111,7 @@ func (r RollupPutJobRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.rollup.rollup_search.go b/esapi/api.xpack.rollup.rollup_search.go index c5cc3ce9f3..b691fc7b02 100644 --- a/esapi/api.xpack.rollup.rollup_search.go +++ b/esapi/api.xpack.rollup.rollup_search.go @@ -126,7 +126,7 @@ func (r RollupRollupSearchRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.searchable_snapshots.mount.go b/esapi/api.xpack.searchable_snapshots.mount.go index 20c5442aff..db834c8b23 100644 --- a/esapi/api.xpack.searchable_snapshots.mount.go +++ b/esapi/api.xpack.searchable_snapshots.mount.go @@ -130,7 +130,7 @@ func (r SearchableSnapshotsMountRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.activate_user_profile.go b/esapi/api.xpack.security.activate_user_profile.go index 79e8f0a9d8..3ad0ff6a86 100644 --- a/esapi/api.xpack.security.activate_user_profile.go +++ b/esapi/api.xpack.security.activate_user_profile.go @@ -104,7 +104,7 @@ func (r SecurityActivateUserProfileRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.change_password.go b/esapi/api.xpack.security.change_password.go index f8641a0e7a..60ac95d61c 100644 --- a/esapi/api.xpack.security.change_password.go +++ b/esapi/api.xpack.security.change_password.go @@ -119,7 +119,7 @@ func (r SecurityChangePasswordRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.create_api_key.go b/esapi/api.xpack.security.create_api_key.go index 0f1af44e0d..89edb774b1 100644 --- a/esapi/api.xpack.security.create_api_key.go +++ b/esapi/api.xpack.security.create_api_key.go @@ -108,7 +108,7 @@ func (r SecurityCreateAPIKeyRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.get_token.go b/esapi/api.xpack.security.get_token.go index 8cd0a38f6e..0894af59a3 100644 --- a/esapi/api.xpack.security.get_token.go +++ b/esapi/api.xpack.security.get_token.go @@ -102,7 +102,7 @@ func (r SecurityGetTokenRequest) Do(ctx context.Context, transport Transport) (* req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.grant_api_key.go b/esapi/api.xpack.security.grant_api_key.go index acdfdf6cf7..5c26bf8868 100644 --- a/esapi/api.xpack.security.grant_api_key.go +++ b/esapi/api.xpack.security.grant_api_key.go @@ -108,7 +108,7 @@ func (r SecurityGrantAPIKeyRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.has_privileges.go b/esapi/api.xpack.security.has_privileges.go index c860daa51e..068aea5900 100644 --- a/esapi/api.xpack.security.has_privileges.go +++ b/esapi/api.xpack.security.has_privileges.go @@ -113,7 +113,7 @@ func (r SecurityHasPrivilegesRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.has_privileges_user_profile.go b/esapi/api.xpack.security.has_privileges_user_profile.go index 170ccf5631..8c456cb87a 100644 --- a/esapi/api.xpack.security.has_privileges_user_profile.go +++ b/esapi/api.xpack.security.has_privileges_user_profile.go @@ -104,7 +104,7 @@ func (r SecurityHasPrivilegesUserProfileRequest) Do(ctx context.Context, transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.invalidate_api_key.go b/esapi/api.xpack.security.invalidate_api_key.go index 3551b9ac8b..cf965d0e19 100644 --- a/esapi/api.xpack.security.invalidate_api_key.go +++ b/esapi/api.xpack.security.invalidate_api_key.go @@ -102,7 +102,7 @@ func (r SecurityInvalidateAPIKeyRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.invalidate_token.go b/esapi/api.xpack.security.invalidate_token.go index 5a2ac247fe..c04d5e8151 100644 --- a/esapi/api.xpack.security.invalidate_token.go +++ b/esapi/api.xpack.security.invalidate_token.go @@ -102,7 +102,7 @@ func (r SecurityInvalidateTokenRequest) Do(ctx context.Context, transport Transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.oidc_authenticate.go b/esapi/api.xpack.security.oidc_authenticate.go index 92b8d5b684..0ef19a9083 100644 --- a/esapi/api.xpack.security.oidc_authenticate.go +++ b/esapi/api.xpack.security.oidc_authenticate.go @@ -102,7 +102,7 @@ func (r SecurityOidcAuthenticateRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.oidc_logout.go b/esapi/api.xpack.security.oidc_logout.go index 1e047ce80b..e8c965b878 100644 --- a/esapi/api.xpack.security.oidc_logout.go +++ b/esapi/api.xpack.security.oidc_logout.go @@ -102,7 +102,7 @@ func (r SecurityOidcLogoutRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.oidc_prepare_authentication.go b/esapi/api.xpack.security.oidc_prepare_authentication.go index 3e1bc7664a..c1587fc91b 100644 --- a/esapi/api.xpack.security.oidc_prepare_authentication.go +++ b/esapi/api.xpack.security.oidc_prepare_authentication.go @@ -102,7 +102,7 @@ func (r SecurityOidcPrepareAuthenticationRequest) Do(ctx context.Context, transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_privileges.go b/esapi/api.xpack.security.put_privileges.go index 030b616259..9ef2fc5e28 100644 --- a/esapi/api.xpack.security.put_privileges.go +++ b/esapi/api.xpack.security.put_privileges.go @@ -108,7 +108,7 @@ func (r SecurityPutPrivilegesRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_role.go b/esapi/api.xpack.security.put_role.go index c29e39971c..c5a35dbda6 100644 --- a/esapi/api.xpack.security.put_role.go +++ b/esapi/api.xpack.security.put_role.go @@ -115,7 +115,7 @@ func (r SecurityPutRoleRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_role_mapping.go b/esapi/api.xpack.security.put_role_mapping.go index 92146060e6..1409d243a6 100644 --- a/esapi/api.xpack.security.put_role_mapping.go +++ b/esapi/api.xpack.security.put_role_mapping.go @@ -115,7 +115,7 @@ func (r SecurityPutRoleMappingRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.put_user.go b/esapi/api.xpack.security.put_user.go index 98f17a7130..5739bfaa15 100644 --- a/esapi/api.xpack.security.put_user.go +++ b/esapi/api.xpack.security.put_user.go @@ -115,7 +115,7 @@ func (r SecurityPutUserRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.query_api_keys.go b/esapi/api.xpack.security.query_api_keys.go index ee47cdbd87..1b6290b8b5 100644 --- a/esapi/api.xpack.security.query_api_keys.go +++ b/esapi/api.xpack.security.query_api_keys.go @@ -102,7 +102,7 @@ func (r SecurityQueryAPIKeysRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_authenticate.go b/esapi/api.xpack.security.saml_authenticate.go index ebf39de440..fda56e9ca8 100644 --- a/esapi/api.xpack.security.saml_authenticate.go +++ b/esapi/api.xpack.security.saml_authenticate.go @@ -102,7 +102,7 @@ func (r SecuritySamlAuthenticateRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_complete_logout.go b/esapi/api.xpack.security.saml_complete_logout.go index 79fbc2b5d5..b0780e32ae 100644 --- a/esapi/api.xpack.security.saml_complete_logout.go +++ b/esapi/api.xpack.security.saml_complete_logout.go @@ -102,7 +102,7 @@ func (r SecuritySamlCompleteLogoutRequest) Do(ctx context.Context, transport Tra req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_invalidate.go b/esapi/api.xpack.security.saml_invalidate.go index 3374f239dd..8172f702e3 100644 --- a/esapi/api.xpack.security.saml_invalidate.go +++ b/esapi/api.xpack.security.saml_invalidate.go @@ -102,7 +102,7 @@ func (r SecuritySamlInvalidateRequest) Do(ctx context.Context, transport Transpo req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_logout.go b/esapi/api.xpack.security.saml_logout.go index 524f2afdb6..2f4e3d0173 100644 --- a/esapi/api.xpack.security.saml_logout.go +++ b/esapi/api.xpack.security.saml_logout.go @@ -102,7 +102,7 @@ func (r SecuritySamlLogoutRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.saml_prepare_authentication.go b/esapi/api.xpack.security.saml_prepare_authentication.go index 4e31f609b9..802e62e62e 100644 --- a/esapi/api.xpack.security.saml_prepare_authentication.go +++ b/esapi/api.xpack.security.saml_prepare_authentication.go @@ -102,7 +102,7 @@ func (r SecuritySamlPrepareAuthenticationRequest) Do(ctx context.Context, transp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.suggest_user_profiles.go b/esapi/api.xpack.security.suggest_user_profiles.go index 4a5af34a26..923ccb3811 100644 --- a/esapi/api.xpack.security.suggest_user_profiles.go +++ b/esapi/api.xpack.security.suggest_user_profiles.go @@ -110,7 +110,7 @@ func (r SecuritySuggestUserProfilesRequest) Do(ctx context.Context, transport Tr req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.update_api_key.go b/esapi/api.xpack.security.update_api_key.go index d0694f2dce..b312694246 100644 --- a/esapi/api.xpack.security.update_api_key.go +++ b/esapi/api.xpack.security.update_api_key.go @@ -109,7 +109,7 @@ func (r SecurityUpdateAPIKeyRequest) Do(ctx context.Context, transport Transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.security.update_user_profile_data.go b/esapi/api.xpack.security.update_user_profile_data.go index 740c6ea1e7..39ff85e957 100644 --- a/esapi/api.xpack.security.update_user_profile_data.go +++ b/esapi/api.xpack.security.update_user_profile_data.go @@ -130,7 +130,7 @@ func (r SecurityUpdateUserProfileDataRequest) Do(ctx context.Context, transport req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.slm.put_lifecycle.go b/esapi/api.xpack.slm.put_lifecycle.go index 5649ceb3c9..55d78340d3 100644 --- a/esapi/api.xpack.slm.put_lifecycle.go +++ b/esapi/api.xpack.slm.put_lifecycle.go @@ -109,7 +109,7 @@ func (r SlmPutLifecycleRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.sql.clear_cursor.go b/esapi/api.xpack.sql.clear_cursor.go index 6c929e06f1..4be7d1784c 100644 --- a/esapi/api.xpack.sql.clear_cursor.go +++ b/esapi/api.xpack.sql.clear_cursor.go @@ -102,7 +102,7 @@ func (r SQLClearCursorRequest) Do(ctx context.Context, transport Transport) (*Re req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.sql.query.go b/esapi/api.xpack.sql.query.go index a5dee2f0e5..e297c37f1b 100644 --- a/esapi/api.xpack.sql.query.go +++ b/esapi/api.xpack.sql.query.go @@ -108,7 +108,7 @@ func (r SQLQueryRequest) Do(ctx context.Context, transport Transport) (*Response req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.sql.translate.go b/esapi/api.xpack.sql.translate.go index 89d822b433..0cb4e701a9 100644 --- a/esapi/api.xpack.sql.translate.go +++ b/esapi/api.xpack.sql.translate.go @@ -102,7 +102,7 @@ func (r SQLTranslateRequest) Do(ctx context.Context, transport Transport) (*Resp req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.text_structure.find_structure.go b/esapi/api.xpack.text_structure.find_structure.go index ca184b538a..1654c6a599 100644 --- a/esapi/api.xpack.text_structure.find_structure.go +++ b/esapi/api.xpack.text_structure.find_structure.go @@ -175,7 +175,7 @@ func (r TextStructureFindStructureRequest) Do(ctx context.Context, transport Tra req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.transform.preview_transform.go b/esapi/api.xpack.transform.preview_transform.go index 4f22362e29..7bdca56ed0 100644 --- a/esapi/api.xpack.transform.preview_transform.go +++ b/esapi/api.xpack.transform.preview_transform.go @@ -118,7 +118,7 @@ func (r TransformPreviewTransformRequest) Do(ctx context.Context, transport Tran req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.transform.put_transform.go b/esapi/api.xpack.transform.put_transform.go index 24e55e22f1..d47664e64f 100644 --- a/esapi/api.xpack.transform.put_transform.go +++ b/esapi/api.xpack.transform.put_transform.go @@ -120,7 +120,7 @@ func (r TransformPutTransformRequest) Do(ctx context.Context, transport Transpor req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.transform.update_transform.go b/esapi/api.xpack.transform.update_transform.go index c49af6cd63..ac152e1488 100644 --- a/esapi/api.xpack.transform.update_transform.go +++ b/esapi/api.xpack.transform.update_transform.go @@ -122,7 +122,7 @@ func (r TransformUpdateTransformRequest) Do(ctx context.Context, transport Trans req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.watcher.execute_watch.go b/esapi/api.xpack.watcher.execute_watch.go index c6ab35000d..6fb61bc03d 100644 --- a/esapi/api.xpack.watcher.execute_watch.go +++ b/esapi/api.xpack.watcher.execute_watch.go @@ -120,7 +120,7 @@ func (r WatcherExecuteWatchRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.watcher.put_watch.go b/esapi/api.xpack.watcher.put_watch.go index f755294d09..b147adad26 100644 --- a/esapi/api.xpack.watcher.put_watch.go +++ b/esapi/api.xpack.watcher.put_watch.go @@ -131,7 +131,7 @@ func (r WatcherPutWatchRequest) Do(ctx context.Context, transport Transport) (*R req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } diff --git a/esapi/api.xpack.watcher.query_watches.go b/esapi/api.xpack.watcher.query_watches.go index 94ecd49be1..2bda80680d 100644 --- a/esapi/api.xpack.watcher.query_watches.go +++ b/esapi/api.xpack.watcher.query_watches.go @@ -102,7 +102,7 @@ func (r WatcherQueryWatchesRequest) Do(ctx context.Context, transport Transport) req.URL.RawQuery = q.Encode() } - if r.Body != nil && req.Header.Get(headerContentType) == "" { + if r.Body != nil { req.Header[headerContentType] = headerContentTypeJSON } From 7f0157549fad95f94414877ddb7b96da1747643f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Saint-F=C3=A9lix?= Date: Mon, 10 Oct 2022 17:16:54 +0200 Subject: [PATCH 3/4] Invert header & body conditions so Header override works on both functional options and direct call --- .../cmd/generate/commands/gensource/generator.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/build/cmd/generate/commands/gensource/generator.go b/internal/build/cmd/generate/commands/gensource/generator.go index 0d7c476ba2..8f74e60c3a 100644 --- a/internal/build/cmd/generate/commands/gensource/generator.go +++ b/internal/build/cmd/generate/commands/gensource/generator.go @@ -30,7 +30,6 @@ import ( ) // Generator represents the "gensource" generator. -// type Generator struct { b bytes.Buffer @@ -38,7 +37,6 @@ type Generator struct { } // Output returns the generator output. -// func (g *Generator) Output() (io.Reader, error) { g.genHeader() g.genConstructor() @@ -52,7 +50,6 @@ func (g *Generator) Output() (io.Reader, error) { } // OutputFormatted returns a formatted generator output. -// func (g *Generator) OutputFormatted() (io.Reader, error) { out, err := g.Output() if err != nil { @@ -825,12 +822,6 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context, req.URL.RawQuery = q.Encode() }` + "\n\n") - if g.Endpoint.Body != nil { - g.w(`if r.Body != nil && req.Header.Get(headerContentType) == "" { - req.Header[headerContentType] = headerContentTypeJSON - }` + "\n\n") - } - g.w(`if len(r.Header) > 0 { if len(req.Header) == 0 { req.Header = r.Header @@ -843,6 +834,12 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(ctx context.Context, } }` + "\n\n") + if g.Endpoint.Body != nil { + g.w(`if r.Body != nil && req.Header.Get(headerContentType) == "" { + req.Header[headerContentType] = headerContentTypeJSON + }` + "\n\n") + } + g.w(`if ctx != nil { req = req.WithContext(ctx) }` + "\n\n") From fc700299670e3c76ce06e7fda4070689dec08c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Saint-F=C3=A9lix?= Date: Mon, 10 Oct 2022 17:17:11 +0200 Subject: [PATCH 4/4] Add test for content-type header override --- elasticsearch_internal_test.go | 94 ++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/elasticsearch_internal_test.go b/elasticsearch_internal_test.go index dd966ad36e..6ee8a6fc71 100644 --- a/elasticsearch_internal_test.go +++ b/elasticsearch_internal_test.go @@ -27,6 +27,7 @@ import ( "crypto/x509" "encoding/base64" "errors" + "github.com/elastic/go-elasticsearch/v8/esapi" "io/ioutil" "net/http" "net/http/httptest" @@ -865,3 +866,96 @@ func TestNewTypedClient(t *testing.T) { t.Fatalf("unexpected error: %s", err) } } + +func TestContentTypeOverride(t *testing.T) { + t.Run("default JSON Content-Type", func(t *testing.T) { + contentType := "application/json" + + tp, _ := elastictransport.New(elastictransport.Config{ + URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, + Transport: &mockTransp{ + RoundTripFunc: func(request *http.Request) (*http.Response, error) { + h := request.Header.Get("Content-Type") + if h != contentType { + t.Fatalf("unexpected content-type, wanted %s, got: %s", contentType, h) + } + + return &http.Response{ + Header: http.Header{"X-Elastic-Product": []string{"Elasticsearch"}}, + StatusCode: http.StatusOK, + Status: "OK", + Body: ioutil.NopCloser(strings.NewReader("")), + }, nil + }, + }, + }) + + c, _ := NewDefaultClient() + c.Transport = tp + + _, _ = c.Search(c.Search.WithBody(strings.NewReader(""))) + }) + t.Run("overriden CBOR Content-Type functional options style", func(t *testing.T) { + contentType := "application/cbor" + + tp, _ := elastictransport.New(elastictransport.Config{ + URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, + Transport: &mockTransp{ + RoundTripFunc: func(request *http.Request) (*http.Response, error) { + h := request.Header.Get("Content-Type") + if h != contentType { + t.Fatalf("unexpected content-type, wanted %s, got: %s", contentType, h) + } + + return &http.Response{ + Header: http.Header{"X-Elastic-Product": []string{"Elasticsearch"}}, + StatusCode: http.StatusOK, + Status: "OK", + Body: ioutil.NopCloser(strings.NewReader("")), + }, nil + }, + }, + }) + + c, _ := NewDefaultClient() + c.Transport = tp + + _, _ = c.Search( + c.Search.WithHeader(map[string]string{ + "Content-Type": contentType, + }), + c.Search.WithBody(strings.NewReader("")), + ) + }) + t.Run("overriden CBOR Content-Type direct call style", func(t *testing.T) { + contentType := "application/cbor" + + tp, _ := elastictransport.New(elastictransport.Config{ + URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, + Transport: &mockTransp{ + RoundTripFunc: func(request *http.Request) (*http.Response, error) { + h := request.Header.Get("Content-Type") + if h != contentType { + t.Fatalf("unexpected content-type, wanted %s, got: %s", contentType, h) + } + + return &http.Response{ + Header: http.Header{"X-Elastic-Product": []string{"Elasticsearch"}}, + StatusCode: http.StatusOK, + Status: "OK", + Body: ioutil.NopCloser(strings.NewReader("")), + }, nil + }, + }, + }) + + c, _ := NewDefaultClient() + c.Transport = tp + + search := esapi.SearchRequest{} + search.Body = strings.NewReader("") + search.Header = make(map[string][]string) + search.Header.Set("Content-Type", contentType) + search.Do(context.Background(), tp) + }) +}