Permalink
Browse files

Merge branch 'bugfix/output-buffer-level-checking'

Fixes #163
  • Loading branch information...
2 parents 3f13653 + 0bccf46 commit 376fd62813eb2008f3644e206d03002a3250122a @Rican7 Rican7 committed Jan 14, 2014
Showing with 17 additions and 5 deletions.
  1. +17 −5 src/Klein/Klein.php
View
@@ -620,20 +620,32 @@ public function dispatch(
// Output capturing behavior
switch($capture) {
case self::DISPATCH_CAPTURE_AND_RETURN:
- return ob_get_clean();
+ $buffed_content = null;
+ if (ob_get_level()) {
+ $buffed_content = ob_get_clean();
+ }
+ return $buffed_content;
break;
case self::DISPATCH_CAPTURE_AND_REPLACE:
- $this->response->body(ob_get_clean());
+ if (ob_get_level()) {
+ $this->response->body(ob_get_clean());
+ }
break;
case self::DISPATCH_CAPTURE_AND_PREPEND:
- $this->response->prepend(ob_get_clean());
+ if (ob_get_level()) {
+ $this->response->prepend(ob_get_clean());
+ }
break;
case self::DISPATCH_CAPTURE_AND_APPEND:
- $this->response->append(ob_get_clean());
+ if (ob_get_level()) {
+ $this->response->append(ob_get_clean());
+ }
break;
case self::DISPATCH_NO_CAPTURE:
default:
- ob_end_flush();
+ if (ob_get_level()) {
+ ob_end_flush();
+ }
}
}

0 comments on commit 376fd62

Please sign in to comment.