Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set x-ms-date for request #24

Open
PureRandom opened this issue May 18, 2021 · 0 comments
Open

Unable to set x-ms-date for request #24

PureRandom opened this issue May 18, 2021 · 0 comments

Comments

@PureRandom
Copy link

When setting the url properties as per below:

ctx := context.TODO()
err = queueUrl.GetProperties(ctx)

It calls the credentials New function (azqueue/zc_credential_shared_key.go line 43).

func (f *SharedKeyCredential) New(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.Policy {
	return pipeline.PolicyFunc(func(ctx context.Context, request pipeline.Request) (pipeline.Response, error) {
		// Add a x-ms-date header if it doesn't already exist
		if d := request.Header.Get(headerXmsDate); d == "" {
			request.Header[headerXmsDate] = []string{time.Now().UTC().Format(http.TimeFormat)}
		}

Within this method it checks if the Header property 'x-ms-date' is set.
If this is not set it is setting it to []string{time.Now().UTC().Format(http.TimeFormat)}

This is setting the value to a UTC time for the authentication, which my local Azure Storage Emulator is rejecting as my local is set to GMT and so the times are not in sync.

I cannot change my local time, not that I should, and I can see there is a check to see if it is already set. Therfore, I believe there should be some method to override/set this header.

I have tried sending a request context:

r.Header.Set("x-ms-date",[]string{time.Now().Format(http.TimeFormat)}[0])
ctx := r.Context()

I have tried setting the context with value

ctx0 := context.TODO()
ctx := context.WithValue(ctx0,"x-ms-date",[]string{time.Now().Format(http.TimeFormat)})

however, each time it gets to the check in the azqueue the header is not set.

How can I set this header value? or should there be a pull request to check this not to assume UTC and use the machine local time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant