Yii2: Request is inconsistent with PSR ServerRequestInterface

Created on 27 Feb 2018  路  4Comments  路  Source: yiisoft/yii2

  1. Send a GET request:
GET http://test.local/test
  1. Call yii\web\Request::getParsedBody()

Expected: null according to PSR

Actual: Exception thrown here

bug

Most helpful comment

Resolved by commit 854ae7127cba009def2496075fc90c03c5699d8c

All 4 comments

The exception your refer indicates that request should have a body according to RFC, e.g. its content type header, but it does not hold any content.
Perhaps, there must be an extra check for empty body somewhere, perhaps not - that is hard to say at the first glance.

Confirmed. This is definitely a bug to be fixed.
At the present state following common controller code throws an exception:

public function actionCreate()
{
    $model = new Foo();
    if ($model->load(Yii::$app->request->post())) { // throws `UnsupportedMediaTypeHttpException`
        $model->save();
    }
    ...
}

Most likely bug was inttroduced during the pursuit for #14522 or #14458

Resolved by commit 854ae7127cba009def2496075fc90c03c5699d8c

Was this page helpful?
0 / 5 - 0 ratings