diff --git a/src/LaunchDarkly.EventSource/EventSourceService.cs b/src/LaunchDarkly.EventSource/EventSourceService.cs
index 87bb171..7e2ff5c 100644
--- a/src/LaunchDarkly.EventSource/EventSourceService.cs
+++ b/src/LaunchDarkly.EventSource/EventSourceService.cs
@@ -256,7 +256,7 @@ private void ValidateResponse(HttpResponseMessage response)
// Any non-2xx response status is an error. A 204 (no content) is also an error.
if (!response.IsSuccessStatusCode || response.StatusCode == System.Net.HttpStatusCode.NoContent)
{
- throw new EventSourceServiceUnsuccessfulResponseException((int)response.StatusCode);
+ throw new EventSourceServiceUnsuccessfulResponseException((int)response.StatusCode, response.Headers);
}
if (response.Content == null)
diff --git a/src/LaunchDarkly.EventSource/EventSourceServiceUnsuccessfulResponseException.cs b/src/LaunchDarkly.EventSource/EventSourceServiceUnsuccessfulResponseException.cs
index c511bc4..ebd2ecf 100644
--- a/src/LaunchDarkly.EventSource/EventSourceServiceUnsuccessfulResponseException.cs
+++ b/src/LaunchDarkly.EventSource/EventSourceServiceUnsuccessfulResponseException.cs
@@ -1,3 +1,4 @@
+using System.Collections.Generic;
namespace LaunchDarkly.EventSource
{
@@ -14,6 +15,11 @@ public class EventSourceServiceUnsuccessfulResponseException : EventSourceServic
///
public int StatusCode { get; }
+ ///
+ /// The HTTP headers from the response.
+ ///
+ public IEnumerable>> Headers { get; }
+
#endregion
#region Public Constructors
@@ -23,9 +29,20 @@ public class EventSourceServiceUnsuccessfulResponseException : EventSourceServic
///
/// the HTTP status code of the response
public EventSourceServiceUnsuccessfulResponseException(int statusCode) :
+ this(statusCode, new Dictionary>())
+ {
+ }
+
+ ///
+ /// Creates a new instance with headers.
+ ///
+ /// the HTTP status code of the response
+ /// the HTTP headers from the response
+ public EventSourceServiceUnsuccessfulResponseException(int statusCode, IEnumerable>> headers) :
base(string.Format(Resources.ErrorHttpStatus, statusCode))
{
StatusCode = statusCode;
+ Headers = headers ?? new Dictionary>();
}
#endregion