Skip to content

Commit a1e6328

Browse files
committed
Address review comments
1 parent faa37a1 commit a1e6328

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

CloudinaryDotNet.Tests/Asset/UrlBuilderTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ public void TestAgentPlatformHeaders()
494494
var httpRequestMessage = CreateRequest("UserPlatform/2.3");
495495

496496
//Can't test the result, so we just verify the UserAgent parameter is sent to the server
497-
StringAssert.IsMatch(@"CloudinaryDotNet\/(\d+)\.(\d+)\.(\d+) \(" + ApiShared.USER_AGENT.Replace("(", "").Replace(")", "") + @"\) UserPlatform/2\.3",
497+
StringAssert.IsMatch(@"CloudinaryDotNet\/(\d+)\.(\d+)\.(\d+) \(" + ApiShared.RUNTIME_INFORMATION.Replace("(", "").Replace(")", "") + @"\) UserPlatform/2\.3",
498498
httpRequestMessage.Headers.UserAgent.ToString());
499499
}
500500

@@ -514,17 +514,17 @@ public void UnexpectedUserPlatformShouldNotThrow(string userPlatorm)
514514
[TestCase("Mono 5.11.0 ((HEAD/768f1b247c6)")]
515515
[TestCase("(")]
516516
[TestCase(")")]
517-
public void MalformedUserAgentShouldNotThrow(string userAgent)
517+
public void MalformedRuntimeInformationShouldNotThrow(string runtimeInformation)
518518
{
519-
var prevAgent = ApiShared.USER_AGENT;
520-
ApiShared.USER_AGENT = userAgent;
519+
var prevAgent = ApiShared.RUNTIME_INFORMATION;
520+
ApiShared.RUNTIME_INFORMATION = runtimeInformation;
521521
try
522522
{
523523
Assert.DoesNotThrow(() => CreateRequest("UserPlatform"));
524524
}
525525
finally
526526
{
527-
ApiShared.USER_AGENT = prevAgent;
527+
ApiShared.RUNTIME_INFORMATION = prevAgent;
528528
}
529529
}
530530

CloudinaryDotNet/ApiShared.Internal.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ private static void AddCommentToUserAgent(
257257
return;
258258
}
259259

260+
// User-Agent's comment section is sensitive to brackets
260261
var normalizedComment = RemoveBracketsFrom(comment);
262+
261263
userAgentHeader.Add(new ProductInfoHeaderValue($"({normalizedComment})"));
262264
}
263265

@@ -478,7 +480,7 @@ private void PrePrepareRequestBody(
478480
var userAgentHeader = request.Headers.UserAgent;
479481
userAgentHeader.Add(new ProductInfoHeaderValue("CloudinaryDotNet", CloudinaryVersion.Full));
480482

481-
AddCommentToUserAgent(userAgentHeader, USER_AGENT);
483+
AddCommentToUserAgent(userAgentHeader, RUNTIME_INFORMATION);
482484
SetUserPlatform(userAgentHeader);
483485

484486
byte[] authBytes = Encoding.ASCII.GetBytes(GetApiCredentials());
@@ -501,7 +503,6 @@ private void PrePrepareRequestBody(
501503

502504
private void SetUserPlatform(HttpHeaderValueCollection<ProductInfoHeaderValue> userAgentHeader)
503505
{
504-
Console.WriteLine($"UserPlatform: [{UserPlatform}] ======");
505506
var up = UserPlatform?.Trim();
506507
if (string.IsNullOrEmpty(up))
507508
{

CloudinaryDotNet/ApiShared.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ public partial class ApiShared : ISignProvider
6969
public const string HTTP_BOUNDARY = "notrandomsequencetouseasboundary";
7070

7171
/// <summary>
72-
/// User agent for cloudinary API requests.
72+
/// Runtime information for cloudinary API requests.
7373
/// </summary>
74-
public static string USER_AGENT = RuntimeInformation.FrameworkDescription;
74+
public static string RUNTIME_INFORMATION = RuntimeInformation.FrameworkDescription;
7575

7676
/// <summary>
7777
/// Whether to use a sub domain.

0 commit comments

Comments
 (0)