Skip to content

Commit 6ede4d2

Browse files
committed
Don't throw on the empty content type
Return the first handler is only one is available.
1 parent 8352dbd commit 6ede4d2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

RestSharp/RestClient.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,12 @@ private static IEnumerable<Parameter> GetQueryStringParameters(IRestRequest requ
476476

477477
private Func<IDeserializer> GetHandler(string contentType)
478478
{
479-
if (contentType == null)
480-
throw new ArgumentNullException(nameof(contentType));
481-
482-
if (string.IsNullOrEmpty(contentType) && ContentHandlers.ContainsKey("*"))
479+
if (contentType.IsEmpty() && ContentHandlers.ContainsKey("*"))
483480
return ContentHandlers["*"];
484481

482+
if (ContentHandlers.Keys.Count == 1)
483+
return ContentHandlers.First().Value;
484+
485485
int semicolonIndex = contentType.IndexOf(';');
486486

487487
if (semicolonIndex > -1)

0 commit comments

Comments
 (0)