Skip to content

OpenStack V2 Authentication Failed since RequestOpts.MoreHeaders does not make sense #2314

@freedywu

Description

@freedywu

In provider_client.go:322, RequestOpts.Header says it will be omitted if it is a blank value.

// RequestOpts customizes the behavior of the provider.Request() method.
type RequestOpts struct {
	// MoreHeaders specifies additional HTTP headers to be provide on the request. If a header is
	// provided with a blank value (""), that header will be *omitted* instead: use this to suppress
	// the default Accept header or an inferred Content-Type, for example.
	MoreHeaders map[string]string
}

But in commit 29581a2 [Swift V1: fix setting empty headers (#2218)], the method locate in ​provider_client.go:411 has been changed, and blank header no longer been removed.

This caused an Authentication Failed error when trying to get an v2auth client due to an empty X-Auth-Token header.
This symptom is imported after v0.21.0.

openstack/identity/v2/tokens/requests.go:94:

resp, err := client.Post(CreateURL(client), b, &r.Body, &gophercloud.RequestOpts{
	OkCodes:     []int{200, 203},
	MoreHeaders: map[string]string{"X-Auth-Token": ""},
})

How can I make it correct? Is there any suggestion or work around?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions