// file_put_contents(self::OUT_DIR . '/a2_upload_in.json', PHP_EOL . date('Y-m-d H:i:s') . ' ', FILE_APPEND | LOCK_EX);
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- $request = Yii::$app->request;
- $result = $request->getBodyParams();
- if (empty($result)) {
- $raw = $request->getRawBody();
- try {
- $result = Json::decode($raw);
- } catch (Exception $ex) {
- return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]);
- }
- }
-
+ $request = Yii::$app->request->getRawBody();
+ $raw = Yii::$app->request->getRawBody();
+ $hdrs = Yii::$app->request->headers;
+
+ Yii::warning([
+ 'method' => Yii::$app->request->method,
+ 'contentType' => (string)$hdrs->get('content-type'),
+ 'contentLength' => (string)$hdrs->get('content-length'),
+ 'encoding' => (string)$hdrs->get('content-encoding'),
+ 'rawLen' => strlen($raw),
+ 'sha1' => sha1($raw),
+ ], 'upload.debug');
+ try {
+ $result = Json::decode($request);
+ } catch (Exception $ex) {
+ return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]);
+ }
if (empty($result)) {
file_put_contents(self::OUT_DIR . '/error_upload.txt',
PHP_EOL . 'result empty', FILE_APPEND);
}
//InfoLogService::setInfoLog(__FILE__, __LINE__, 'upload_' . $fl . '.json' , 'info_id_25_1');
- file_put_contents(self::OUT_DIR . '/upload_' . $fl . '.json', PHP_EOL . $request->getRawBody());
+ file_put_contents(self::OUT_DIR . '/upload_' . $fl . '.json', PHP_EOL . $request);
try {
$mess = [];