Skip to content

Commit

Permalink
Throw better exception when response has no body and the user want to…
Browse files Browse the repository at this point in the history
… read it.
  • Loading branch information
honfika committed Apr 25, 2020
1 parent 5a4f1af commit f207689
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Titanium.Web.Proxy/Http/Response.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using Titanium.Web.Proxy.Exceptions;
using Titanium.Web.Proxy.Extensions;
using Titanium.Web.Proxy.Models;

Expand Down Expand Up @@ -118,6 +119,11 @@ internal override void EnsureBodyAvailable(bool throwWhenNotReadYet = true)
return;
}

if (!HasBody)
{
throw new BodyNotFoundException("Response don't have a body.");
}

if (!IsBodyRead && throwWhenNotReadYet)
{
throw new Exception("Response body is not read yet. " +
Expand Down

0 comments on commit f207689

Please sign in to comment.