Index: Src/GoogleApis/Apis/Services/BaseClientService.cs
===================================================================
--- a/Src/GoogleApis/Apis/Services/BaseClientService.cs
+++ b/Src/GoogleApis/Apis/Services/BaseClientService.cs
@@ -32,6 +32,7 @@
using Google.Apis.Logging;
using Google.Apis.Requests;
using Google.Apis.Util;
+using Google.Apis.Testing;
namespace Google.Apis.Services
{
@@ -51,6 +52,10 @@
/// The class logger.
private static readonly ILogger Logger = ApplicationContext.Logger.ForType();
+ /// The default maximum allowed length of a URL string for GET requests.
+ [VisibleForTestOnly]
+ internal const uint DefaultMaxUrlLength = 2048;
+
#region Initializer
/// An initializer class for the client service.
@@ -102,6 +107,12 @@
///
public string ApplicationName { get; set; }
+ ///
+ /// Maximum allowed length of a URL string for GET requests. Default value is 2048. If the value is
+ /// set to 0, requests will never be modified due to URL string length.
+ ///
+ public uint MaxUrlLength { get; set; }
+
/// Constructs a new initializer with default values.
public Initializer()
{
@@ -109,6 +120,7 @@
Serializer = new NewtonsoftJsonSerializer();
Authenticator = NullAuthenticator.Instance;
DefaultExponentialBackOffPolicy = ExponentialBackOffPolicy.UnsuccessfulResponse503;
+ MaxUrlLength = DefaultMaxUrlLength;
}
}
@@ -165,8 +177,14 @@
// Add authenticator initializer to intercept a request and add the "Authorization" header and also handle
// abnormal 401 responses in case the authenticator is an instance of unsuccessful response handler.
args.Initializers.Add(new AuthenticatorMessageHandlerInitializer(Authenticator));
-
- return factory.CreateHttpClient(args);
+
+ var httpClient = factory.CreateHttpClient(args);
+ if (initializer.MaxUrlLength > 0)
+ {
+ httpClient.MessageHandler.ExecuteInterceptors.Add(
+ new MaxUrlLengthInterceptor(initializer.MaxUrlLength));
+ }
+ return httpClient;
}
///