Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix when handling requests with empty body #2153

Closed
wants to merge 1 commit into from
Closed

Bugfix when handling requests with empty body #2153

wants to merge 1 commit into from

Conversation

dhm80
Copy link

@dhm80 dhm80 commented Feb 20, 2017

If you call a page with e. g. Method GET and ContentType text/xml the method getParsedBody() throws an Exception as $this->bodyis always set (as it contains a StreamInterface) if the body is empty.

The correct procedure would be to check if the body has content.

If you call a page with e. g. Method ```GET``` and ContentType ```text/xml``` the method ```getParsedBody()``` throws an Exception as ```$this->body```is always set (as it contains a StreamInterface). The correct procedure would be to check if the body has content.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.954% when pulling afe1b95 on dhm80:patch-1 into c138554 on slimphp:3.x.

@akrabat
Copy link
Member

akrabat commented Feb 20, 2017

Please create a unit test and supply a curl command that shows the problem.

Thanks.

@akrabat
Copy link
Member

akrabat commented Mar 18, 2017

I can't reproduce with this test:

    public function testGetParsedBodyXmlWithNoBody()
    {
        $method = 'GET';
        $uri = new Uri('https', 'example.com', 443);
        $headers = new Headers();
        $headers->set('Content-Type', 'application/xml');
        $cookies = [];
        $serverParams = [];
        $body = new RequestBody();
        $body->write('');
        $request = new Request($method, $uri, $headers, $cookies, $serverParams, $body);

        $this->assertEquals('', $request->getParsedBody());
    }

Please write a test that shows the problem and add to this branch and then reopen the PR.

@akrabat akrabat closed this Mar 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants