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

Default Request Headers are double added on Android #28

Closed
daniel-rck opened this issue Jun 24, 2019 · 6 comments · Fixed by #29
Closed

Default Request Headers are double added on Android #28

daniel-rck opened this issue Jun 24, 2019 · 6 comments · Fixed by #29
Labels
bug Something isn't working

Comments

@daniel-rck
Copy link
Contributor

daniel-rck commented Jun 24, 2019

Describe the bug
A HttpClient with client.DefaultRequestHeaders.Add("x-api-key", myApiKey); is signed correctly, but the client itself adds the header twice into the request:

"Headers": [
{
  "Key": "x-api-key",
  "Value": [
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ]
},
{
  "Key": "X-Amz-Date",
  "Value": [
...
}

To Reproduce
Steps to reproduce the behavior:
Try this code:

var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", accessToken);

// do a random request
var response = await client.GetAsync(requestUri, cancellationToken, regionName, serviceName, credentials);

You can see the request object before sending here.

Compare to the request object that is return in response.RequestMessage.

Expected behavior
The Request Header should contain the header "x-api-key" only once. Like this:

"Headers": [
{
  "Key": "x-api-key",
  "Value": [
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ]
},
{
  "Key": "X-Amz-Date",
  "Value": [
...
}

Environment (please complete the following information):

  • AWS API Gateway]
  • OS: Android 8.0
  • .NET version: Mono.Android

Additional context
I have tested an .NET Core 2.1 Console application where everything runs fine.

@daniel-rck daniel-rck added the bug Something isn't working label Jun 24, 2019
@FantasticFiasco
Copy link
Owner

I'll be damned, I though the .NET behavior was identical on all platforms.

I'll take a look at #29, but I am currently on holiday and wont be able to release anything until tonight or tomorrow night. Is there a way for you to work around this issue until the new version is released?

@daniel-rck
Copy link
Contributor Author

Nevermind, I'm using my own fork right now - at least until there is a fixed version released.
Thank you and keep up the good work! :)

@FantasticFiasco
Copy link
Owner

FantasticFiasco commented Jun 26, 2019

I've released a preview on www.nuget.org. Would it be possible for you to verify that this preview is working in your environment? In case it does, I will continue with releasing the official version.

@daniel-rck
Copy link
Contributor Author

👍 works with 1.0.2-sha-2b78963.

FantasticFiasco pushed a commit that referenced this issue Jun 27, 2019
The behavior on Mono is different from the behavior on .NET Framework or .NET Core, where a default request header that already exists on the request message is ignored.

Closes #28
@FantasticFiasco
Copy link
Owner

The new official v1.0.2 is now live on www.nuget.org.

Thank you so much for reporting this issue, and good luck to you on your future development adventures!

@daniel-rck
Copy link
Contributor Author

Thank you for the fast response and fix, all the best likewise :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants