Skip to content

Commit d2ad585

Browse files
committed
🚿
1 parent a0fdc31 commit d2ad585

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/HeaderUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace chillerlan\HTTP\Utils;
1212

13-
use function array_keys, array_map, array_values, count, explode, implode,
13+
use function array_keys, array_values, count, explode, implode,
1414
is_array, is_numeric, is_string, strtolower, trim, ucfirst;
1515

1616
/**

src/MessageUtil.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@
2222
final class MessageUtil{
2323

2424
/**
25-
* Read the message body's content
25+
* Read the message body's content, throws if the content could not be read from the message body
26+
*
27+
* @throws \RuntimeException
2628
*/
2729
public static function getContents(MessageInterface $message):string{
28-
return StreamUtil::getContents($message->getBody());
30+
$content = StreamUtil::getContents($message->getBody());
31+
32+
if($content === null){
33+
throw new RuntimeException('invalid message content');
34+
}
35+
36+
return $content;
2937
}
3038

3139
/**

0 commit comments

Comments
 (0)