Skip to content

Commit

Permalink
Merge branch 'bugfix/output-buffer-level-checking'
Browse files Browse the repository at this point in the history
Fixes #163
  • Loading branch information
Rican7 committed Jan 14, 2014
2 parents 3f13653 + 0bccf46 commit 376fd62
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/Klein/Klein.php
Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 376fd62

Please sign in to comment.