Skip to content

Commit 5f99dec

Browse files
committed
Merge branch 'v4.1' into v4.2
2 parents d15dc97 + 1694188 commit 5f99dec

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace DotNetOpenAuth.Messaging {
99
using System.ComponentModel;
1010
using System.Diagnostics.CodeAnalysis;
1111
using System.Diagnostics.Contracts;
12+
using System.Globalization;
1213
using System.IO;
1314
using System.Net;
1415
using System.Net.Mime;
@@ -318,6 +319,7 @@ internal void SetResponse(string body, ContentType contentType) {
318319
writer.Write(body);
319320
writer.Flush();
320321
this.ResponseStream.Seek(0, SeekOrigin.Begin);
322+
this.Headers[HttpResponseHeader.ContentLength] = this.ResponseStream.Length.ToString(CultureInfo.InvariantCulture);
321323
}
322324

323325
/// <summary>

src/DotNetOpenAuth.OAuth2.Client/OAuth2/BearerTokenHttpMessageHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public BearerTokenHttpMessageHandler(ClientBase client, IAuthorizationState auth
7575
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {
7676
string bearerToken = this.BearerToken;
7777
if (bearerToken == null) {
78-
ErrorUtilities.VerifyProtocol(!this.Authorization.AccessTokenExpirationUtc.HasValue || this.Authorization.AccessTokenExpirationUtc < DateTime.UtcNow || this.Authorization.RefreshToken != null, ClientStrings.AuthorizationExpired);
78+
ErrorUtilities.VerifyProtocol(!this.Authorization.AccessTokenExpirationUtc.HasValue || this.Authorization.AccessTokenExpirationUtc >= DateTime.UtcNow || this.Authorization.RefreshToken != null, ClientStrings.AuthorizationExpired);
7979

8080
if (this.Authorization.AccessTokenExpirationUtc.HasValue && this.Authorization.AccessTokenExpirationUtc.Value < DateTime.UtcNow) {
8181
ErrorUtilities.VerifyProtocol(this.Authorization.RefreshToken != null, ClientStrings.AccessTokenRefreshFailed);

src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public MailAddress MailAddress {
192192
}
193193

194194
/// <summary>
195-
/// Gets or sets a combination o the language and country of the user.
195+
/// Gets or sets a combination of the language and country of the user.
196196
/// </summary>
197197
[XmlIgnore]
198198
public CultureInfo Culture {
@@ -203,7 +203,16 @@ public CultureInfo Culture {
203203
if (!string.IsNullOrEmpty(this.Country)) {
204204
cultureString += "-" + this.Country;
205205
}
206-
this.culture = CultureInfo.GetCultureInfo(cultureString);
206+
207+
// language-country may not always form a recongized valid culture.
208+
// For instance, a Google OpenID Provider can return a random combination
209+
// of language and country based on user settings.
210+
try {
211+
this.culture = CultureInfo.GetCultureInfo(cultureString);
212+
} catch (CultureNotFoundException) {
213+
// Fallback to just reporting a culture based on language.
214+
this.culture = CultureInfo.GetCultureInfo(this.Language);
215+
}
207216
}
208217

209218
return this.culture;

0 commit comments

Comments
 (0)