Skip to content

Fixed bug in content length calculation#1984

Merged
jessevz merged 1 commit intodevfrom
1983-bug-swagger-apidocs-broken
Mar 16, 2026
Merged

Fixed bug in content length calculation#1984
jessevz merged 1 commit intodevfrom
1983-bug-swagger-apidocs-broken

Conversation

@jessevz
Copy link
Copy Markdown
Contributor

@jessevz jessevz commented Mar 16, 2026

In the backend, the content length was generated before compressing the payload. The reult was for big files like the openapi.json is that the content length would be too big, making the server time out waiting for data it wont receive

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a bug where ContentLengthMiddleware was calculating the content length before DeflateEncoder compressed the response body, causing incorrect Content-Length headers and client timeouts on large responses like openapi.json.

Changes:

  • Reordered Slim middleware so ContentLengthMiddleware runs after DeflateEncoder on the response path, ensuring content length reflects the compressed body size.
  • Removed JSON_PRETTY_PRINT from the OpenAPI schema JSON encoding.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/api/v2/index.php Moved ContentLengthMiddleware after DeflateEncoder in the middleware stack
src/inc/apiv2/common/openAPISchema.routes.php Removed JSON_PRETTY_PRINT flag from JSON encoding

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/inc/apiv2/common/openAPISchema.routes.php
@jessevz jessevz merged commit 474b240 into dev Mar 16, 2026
8 checks passed
@jessevz jessevz deleted the 1983-bug-swagger-apidocs-broken branch March 16, 2026 13:48
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.

3 participants