Skip to content

Commit 36fed4c

Browse files
committed
Merge branch 'v4.2' into v4.3
Conflicts: src/version.txt
2 parents 3348abf + 5f99dec commit 36fed4c

4 files changed

Lines changed: 15 additions & 4 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.Core/Messaging/StandardWebRequestHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public IncomingWebResponse GetResponse(HttpWebRequest request, DirectWebRequestO
167167
}
168168
} else {
169169
Logger.Http.ErrorFormat(
170-
"{0} connecting to {0}",
170+
"{0} connecting to {1}",
171171
ex.Status,
172172
request.RequestUri);
173173
}

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)