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

fix: respondNoContent() returns Kint script in development mode #7347

Merged
merged 2 commits into from
Mar 17, 2023
Merged

fix: respondNoContent() returns Kint script in development mode #7347

merged 2 commits into from
Mar 17, 2023

Conversation

anggadarkprince
Copy link
Contributor

@anggadarkprince anggadarkprince commented Mar 9, 2023

Description
Fixes #7346 about API\ResponseTrait::respondNoContent() returns Kint script in development mode.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added GPG-Signing needed Pull requests that need GPG-Signing tests needed Pull requests that need tests bug Verified issues on the current code behavior or pull requests that will fix them labels Mar 9, 2023
@kenjis
Copy link
Member

kenjis commented Mar 9, 2023

@kenjis
Copy link
Member

kenjis commented Mar 14, 2023

@anggadarkprince
Copy link
Contributor Author

is it correct now?

@kenjis kenjis removed the GPG-Signing needed Pull requests that need GPG-Signing label Mar 14, 2023
@kenjis
Copy link
Member

kenjis commented Mar 14, 2023

Good! Thank you.

@anggadarkprince
Copy link
Contributor Author

I add content type checking on unit test, to make sure it returns non-HTML format,

public function testNoContent()
{
    $controller = $this->makeController();

    $this->invoke($controller, 'respondNoContent', ['']);

    $this->assertStringStartsWith('application/json', $this->response->getHeaderLine('Content-Type'));
    $this->assertSame('No Content', $this->response->getReason());
    $this->assertSame(204, $this->response->getStatusCode());
}

because in Toolbar.php it checks the type

// Non-HTML formats should not include the debugbar
// then we send headers saying where to find the debug data
 // for this response
 if ($request->isAJAX() || strpos($format, 'html') === false) {
    $response->setHeader('Debugbar-Time', "{$time}")
         ->setHeader('Debugbar-Link', site_url("?debugbar_time={$time}"));

    return;
}

@kenjis kenjis removed the tests needed Pull requests that need tests label Mar 15, 2023
@MGatner MGatner merged commit c4ff7c7 into codeigniter4:develop Mar 17, 2023
@MGatner
Copy link
Member

MGatner commented Mar 17, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: API\ResponseTrait::respondNoContent() returns Kint script in development mode
3 participants