Commit f814d24
committed
Add multipart/form-data file upload and cookie management features
This commit introduces two major features for Transport PHP:
## Feature 1: Multipart/Form-Data File Upload
- Add `Part` class for representing multipart form components
- Add `MultipartStreamBuilder` for RFC 7578 compliant multipart streams
- Add `withMultipart()`, `withFile()`, and `withMultipartBuilder()` methods to RequestBuilder
- Support for mixed text fields and file uploads in single request
- Automatic content-type detection based on file extensions
- Custom boundaries, filenames, and content-types support
- PSR-7 StreamInterface compliance for memory-efficient operations
## Feature 2: Cookie Management
- Add `Cookie` class with RFC 6265 compliance
- Add `CookieJar` for cookie storage with domain/path matching
- Add `CookieMiddleware` for automatic cookie handling
- Add `withCookies()` and `withCookieJar()` methods to TransportBuilder
- Support for session and persistent cookies
- Automatic cookie expiration handling
- Cookie export/import for persistence
- Secure/HttpOnly/SameSite attribute support
- Proper domain and path matching algorithms
## Testing & Quality
- Add comprehensive test suite (55+ new tests, 330 total passing)
- Add practical examples (file-upload.php, cookie-session.php)
- Update README with feature documentation and usage examples
- PSR-12 code style compliance
- Full type safety with PHP 8.1+ strict types
## Breaking Changes
None - fully backward compatible with existing code.
Closes #24 (if applicable)1 parent 8ded390 commit f814d24
12 files changed
Lines changed: 2721 additions & 0 deletions
File tree
- examples
- src
- Cookie
- Middleware
- Multipart
- tests
- Cookie
- Multipart
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
245 | 348 | | |
246 | 349 | | |
247 | 350 | | |
| |||
346 | 449 | | |
347 | 450 | | |
348 | 451 | | |
| 452 | + | |
| 453 | + | |
349 | 454 | | |
350 | 455 | | |
351 | 456 | | |
| |||
0 commit comments