JornWildt / Ramone

A C# client framework for consuming HTTP/REST services
Other
61 stars 11 forks source link

ArgumentOutOfRangeException when WWW-Authenticate header in response only contains the scheme #52

Closed MortenAanaes closed 1 year ago

MortenAanaes commented 2 years ago

I got a http response where the WWW-Authenticate header contains the schema, but no parameters:

WWW-Authenticate: Bearer

This is legal according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate#syntax.

Ramone throws with the following stacktrace:


System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Ramone.BaseRequest.HandleUnauthorized(HttpWebResponse response, WebException ex)
   at Ramone.BaseRequest.HandleWebException(WebException ex, Uri url, String method, Boolean includeBody, Action`1 requestModifier, Int32 retryLevel)
   at Ramone.BaseRequest.DoRequest(Uri url, String method, Boolean includeBody, Action`1 requestModifier, Int32 retryLevel)
   at Ramone.BaseRequest.DoRequest[TResponse](String method, Int32 retryLevel)