@@ -325,10 +325,12 @@ type RequestOpts struct {
325325 // OkCodes contains a list of numeric HTTP status codes that should be interpreted as success. If
326326 // the response has a different code, an error will be returned.
327327 OkCodes []int
328- // MoreHeaders specifies additional HTTP headers to be provide on the request. If a header is
329- // provided with a blank value (""), that header will be *omitted* instead: use this to suppress
330- // the default Accept header or an inferred Content-Type, for example.
328+ // MoreHeaders specifies additional HTTP headers to be provided on the request.
329+ // MoreHeaders will be overridden by OmitHeaders
331330 MoreHeaders map [string ]string
331+ // OmitHeaders specifies the HTTP headers which should be omitted.
332+ // OmitHeaders will override MoreHeaders
333+ OmitHeaders []string
332334 // ErrorContext specifies the resource error type to return if an error is encountered.
333335 // This lets resources override default error messages based on the response status code.
334336 ErrorContext error
@@ -396,7 +398,8 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
396398 req = req .WithContext (client .Context )
397399 }
398400
399- // Populate the request headers. Apply options.MoreHeaders last, to give the caller the chance to
401+ // Populate the request headers.
402+ // Apply options.MoreHeaders and options.OmitHeaders, to give the caller the chance to
400403 // modify or omit any header.
401404 if contentType != nil {
402405 req .Header .Set ("Content-Type" , * contentType )
@@ -412,6 +415,10 @@ func (client *ProviderClient) doRequest(method, url string, options *RequestOpts
412415 }
413416 }
414417
418+ for _ , v := range options .OmitHeaders {
419+ req .Header .Del (v )
420+ }
421+
415422 // get latest token from client
416423 for k , v := range client .AuthenticatedHeaders () {
417424 req .Header .Set (k , v )
0 commit comments