Skip to content

Conversation

@JosePineiro
Copy link

This PR refactors a single overload of the AsyncFileResponse constructor. The changes improve speed, readability and maintainability by:

  • Replacing the strlen(contentType) == 0 check
  • Restructuring the logic for setting the Content-Disposition header. Explicitly separates inline serving from download attachments.
  • Not altering behavior.

This PR refactors a single overload of the AsyncFileResponse constructor. The changes improve speed, readability and maintainability by:
- Replacing the strlen(contentType) == 0 check
- Restructuring the logic for setting the Content-Disposition header. Explicitly separates inline serving from download attachments.
- Not altering behavior.
@mathieucarbou mathieucarbou requested a review from Copilot August 22, 2025 17:14
@mathieucarbou mathieucarbou changed the title Refactor AsyncFileResponse (File overload) Fix: Refactor AsyncFileResponse (File overload) Aug 22, 2025
Copy link

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

This PR refactors the AsyncFileResponse constructor overload to improve performance and code maintainability while preserving existing behavior. The changes optimize string operations and clarify the logic for setting Content-Disposition headers.

  • Optimizes empty string check by replacing strlen(contentType) == 0 with *contentType == '\0'
  • Restructures Content-Disposition header logic to clearly separate inline serving from download attachments
  • Replaces hardcoded strings with template constants and simplifies buffer handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mathieucarbou
Copy link
Member

Thanks a lot @JosePineiro 👍

Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mathieucarbou mathieucarbou requested a review from Copilot August 25, 2025 12:42
Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mathieucarbou mathieucarbou merged commit 197a37b into ESP32Async:main Aug 25, 2025
33 checks passed
@JosePineiro JosePineiro deleted the refactor/asyncfileresponse-File branch August 25, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants