Skip to content

Commit da0932c

Browse files
authored
Merge pull request #7 from xzag/empty-response-fix
empty response fix
2 parents ebf1ab0 + 462e717 commit da0932c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

JsonRpcRequest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use yii\web\Application;
1515
use yii\web\BadRequestHttpException;
1616
use yii\web\NotFoundHttpException;
17+
use yii\web\Response;
1718

1819
/**
1920
* Class JsonRpcRequest
@@ -193,6 +194,16 @@ public function execute()
193194
} catch (\Exception $e) {
194195
throw new InternalErrorException('Internal error', [], $e);
195196
}
197+
198+
if (is_null($result)) {
199+
// in case we don't have any response (e.g. notification request)
200+
// we should return nothing
201+
// without this fix json response formatter will return 'null'
202+
\Yii::$app->response->format = Response::FORMAT_RAW;
203+
\Yii::$app->response->data = null;
204+
\Yii::$app->end();
205+
}
206+
196207
return $result;
197208
}
198209
}

0 commit comments

Comments
 (0)