Fixes format exception thrown when user agent header value is incorrect#283
Fixes format exception thrown when user agent header value is incorrect#283
Conversation
| ApiShared.USER_AGENT = userAgent; | ||
| try | ||
| { | ||
| var httpRequestMessage = CreateRequest("UserPlatform"); |
There was a problem hiding this comment.
It would be better also to check that it is serialized correctly
There was a problem hiding this comment.
@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
| /// 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.
The name of this constant does not correspond the content. Very confusing. Please refactor.
|
|
||
| private void SetUserPlatform(HttpHeaderValueCollection<ProductInfoHeaderValue> userAgentHeader) | ||
| { | ||
| Console.WriteLine($"UserPlatform: [{UserPlatform}] ======"); |
There was a problem hiding this comment.
Please remove debug printing.
| var productVersion = GetElement(1); | ||
| if (string.IsNullOrEmpty(productVersion)) | ||
| { | ||
| productVersion = "0.1"; |
There was a problem hiding this comment.
"0.1" ? is there any special meaning?
There was a problem hiding this comment.
@const-cloudinary No special meaning here, just a default value.
| return; | ||
| } | ||
|
|
||
| var normalizedComment = RemoveBracketsFrom(comment); |
There was a problem hiding this comment.
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.