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

Fixes format exception thrown when user agent header value is incorrect #283

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

YomesInc
Copy link
Contributor

@YomesInc YomesInc commented Jul 9, 2021

No description provided.

ApiShared.USER_AGENT = userAgent;
try
{
var httpRequestMessage = CreateRequest("UserPlatform");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better also to check that it is serialized correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@const-cloudinary We think that such a check would be complicated and nonobvious (need to use regex etc. like in TestAgentPlatformHeaders). These tests were added to assert that "bad" data won't break anything — DoesNotThrow seems to be fine here.

@@ -71,7 +71,7 @@ public partial class ApiShared : ISignProvider
/// <summary>
/// User agent for cloudinary API requests.
/// </summary>
public static string USER_AGENT = BuildUserAgent();
public static string USER_AGENT = RuntimeInformation.FrameworkDescription;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this constant does not correspond the content. Very confusing. Please refactor.

@@ -478,6 +499,36 @@ private void SetChunkedEncoding(HttpRequestMessage request)
}
}

private void SetUserPlatform(HttpHeaderValueCollection<ProductInfoHeaderValue> userAgentHeader)
{
Console.WriteLine($"UserPlatform: [{UserPlatform}] ======");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove debug printing.

var productVersion = GetElement(1);
if (string.IsNullOrEmpty(productVersion))
{
productVersion = "0.1";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"0.1" ? is there any special meaning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@const-cloudinary No special meaning here, just a default value.

return;
}

var normalizedComment = RemoveBracketsFrom(comment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain the problem we are solving here. In a year nobody will remember why we remove brackets from headers.

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

Successfully merging this pull request may close these issues.

None yet

2 participants