Skip to content

Commit

Permalink
Explain bug #41
Browse files Browse the repository at this point in the history
  • Loading branch information
imsamurai committed Sep 5, 2014
1 parent b8e1c31 commit 66ba260
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Test/Case/Controller/HttpSourceControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testExplain($method, array $logData, $debugLevel, $exception) {
'return' => 'view'
));

$this->assertStringMatchesFormat('%w<table class="sql-log-query-explain debug-table">%w' . $explaination . '%w</table>%w', $view);
$this->assertStringMatchesFormat('%w<div class="sql-log-query-explain debug-table" style="white-space:pre;">%w' . $explaination . '%w</div>%w', $view);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Utility/HttpSourceUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function explainQuery($query, $verboseLevel = 4, $timeout = 5) {
}

$Process->run();
return $Process->getOutput();
return trim($Process->getOutput());
}

/**
Expand All @@ -57,7 +57,7 @@ public static function explainQuery($query, $verboseLevel = 4, $timeout = 5) {
* @return boolean
*/
public static function parseQuery($query) {
$success = preg_match("/^(?P<method>GET|POST|PUT|DELETE|HEAD)\s(?P<path>\S+)\s(?P<httpVer>\S+)\sHost:\s(?P<host>[^\s:]+)(:(?P<port>[0-9]+)|)\s(?P<headers>.*)\n\n(?P<body>.*)$/ims", ltrim($query), $matches);
$success = preg_match("/^(?P<method>GET|POST|PUT|DELETE|HEAD)\s(?P<path>\S+)\s(?P<httpVer>\S+)\s*Host:\s(?P<host>[^\s:]+)(:(?P<port>[0-9]+)|)\s*(?P<headers>.*)\s{2,}(?P<body>.*)$/ims", ltrim($query), $matches);
if (!$success) {
return false;
}
Expand All @@ -67,7 +67,7 @@ public static function parseQuery($query) {
'httpVer' => $matches['httpVer'],
'host' => $matches['host'],
'port' => empty($matches['port']) ? 80 : (int)$matches['port'],
'headers' => explode("\n", $matches['headers']),
'headers' => array_filter(array_map('trim', explode("\n", $matches['headers']))),
'body' => $matches['body']
);
}
Expand Down
4 changes: 2 additions & 2 deletions View/HttpSource/explain.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* Format: http://book.cakephp.org/2.0/en/views.html
*/
?>
<table class="sql-log-query-explain debug-table">
<div class="sql-log-query-explain debug-table" style="white-space:pre;">
<?= $result; ?>
</table>
</div>

0 comments on commit 66ba260

Please sign in to comment.