-
Notifications
You must be signed in to change notification settings - Fork 69
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
base: master
Are you sure you want to change the base?
Conversation
ApiShared.USER_AGENT = userAgent; | ||
try | ||
{ | ||
var httpRequestMessage = CreateRequest("UserPlatform"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
CloudinaryDotNet/ApiShared.cs
Outdated
@@ -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; |
There was a problem hiding this comment.
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}] ======"); |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
fd47eea
to
a1e6328
Compare
No description provided.