dio
dio copied to clipboard
Fix FormData clone boundary inconsistency issue
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
initBoundaryparameter to the FormData constructor. - Implemented boundary reuse logic when cloning FormData objects.
- Updated documentation to explain how
initBoundaryaffectsboundaryName.
Technical details:
- The
FormDataconstructor now accepts an optionalinitBoundaryparameter. - When
initBoundaryis provided, it overrides theboundaryNameconfiguration. - 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
mainbranch 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.mdin the corresponding package