Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit f207689

Browse files
committed
Throw better exception when response has no body and the user want to read it.
1 parent 5a4f1af commit f207689

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Titanium.Web.Proxy/Http/Response.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel;
3+
using Titanium.Web.Proxy.Exceptions;
34
using Titanium.Web.Proxy.Extensions;
45
using Titanium.Web.Proxy.Models;
56

@@ -118,6 +119,11 @@ internal override void EnsureBodyAvailable(bool throwWhenNotReadYet = true)
118119
return;
119120
}
120121

122+
if (!HasBody)
123+
{
124+
throw new BodyNotFoundException("Response don't have a body.");
125+
}
126+
121127
if (!IsBodyRead && throwWhenNotReadYet)
122128
{
123129
throw new Exception("Response body is not read yet. " +

0 commit comments

Comments
 (0)