dio icon indicating copy to clipboard operation
dio copied to clipboard

Fix FormData clone boundary inconsistency issue

Open helloliuyiming opened this issue 1 year ago • 0 comments

Resolves https://github.com/cfug/dio/issues/2303

Fix boundary inconsistency in FormData.clone method

Description:

This PR addresses an issue where cloning FormData objects resulted in different boundaries each time. The problem was caused by allocating a new boundary for each clone without any boundary reuse logic.

Changes made:

  • Added an initBoundary parameter to the FormData constructor.
  • Implemented boundary reuse logic when cloning FormData objects.
  • Updated documentation to explain how initBoundary affects boundaryName.

Technical details:

  • The FormData constructor now accepts an optional initBoundary parameter.
  • When initBoundary is provided, it overrides the boundaryName configuration.
  • The cloning process now reuses the existing boundary when appropriate.

Impact: This fix ensures consistent behavior when cloning FormData objects and improves efficiency by reusing boundaries where possible. It should resolve issues related to unexpected boundary changes during FormData manipulation.

Testing:

  • Added unit tests to verify boundary consistency across cloned FormData objects.
  • Manually tested with various use cases to ensure backwards compatibility.

Note to reviewers: Please pay special attention to the boundary reuse logic and any potential side effects on existing FormData usage.

New Pull Request Checklist

  • [ ] I have read the Documentation
  • [ ] I have searched for a similar pull request in the project and found none
  • [ ] I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • [ ] I have added the required tests to prove the fix/feature I'm adding
  • [ ] I have updated the documentation (if necessary)
  • [ ] I have run the tests without failures
  • [ ] I have updated the CHANGELOG.md in the corresponding package

helloliuyiming avatar Oct 03 '24 04:10 helloliuyiming