Commit d0d1fbb
[bugfix] http-client: byte-safe multipart response parsing with nesting
A multipart response was split with String.split("--" + boundary) over a UTF-8
decode of the body, which corrupts any binary part (a non-UTF-8 byte sequence
does not survive the String round-trip), and a nested multipart part was not
parsed recursively.
splitMultipart, extractPartContentType, and extractPartBody now operate on the
raw bytes: the body is split at the boundary using a byte-level search, each
part's header region is decoded as ISO-8859-1 (a total byte->char map) only to
read the Content-Type, and the part body is sliced as bytes -- so a binary part
round-trips byte-for-byte. addBody now recurses into a part whose media type is
multipart/*, so nested multipart responses surface their leaf parts.
SendRequestFunctionTest gains multipartBinaryPartIsByteSafe (a 0xFF 0xFE part
round-trips as base64Binary "//4=") and multipartNestedIsParsedRecursively
(outer[ multipart[A,B], C ] -> A,B,C). The two new endpoints are registered in a
helper to keep startHttpServer's complexity unchanged.
Per-part header reproduction in the http:multipart descriptor remains a follow-up.
Part of #6512
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 4f238d8 commit d0d1fbb
2 files changed
Lines changed: 165 additions & 26 deletions
File tree
- extensions/modules/http-client/src
- main/java/org/exist/xquery/modules/httpclient
- test/java/org/exist/xquery/modules/httpclient
Lines changed: 90 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
188 | 192 | | |
189 | 193 | | |
190 | 194 | | |
| |||
270 | 274 | | |
271 | 275 | | |
272 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
273 | 284 | | |
274 | | - | |
275 | | - | |
276 | | - | |
| 285 | + | |
277 | 286 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
282 | 297 | | |
283 | | - | |
| 298 | + | |
284 | 299 | | |
285 | 300 | | |
286 | 301 | | |
287 | 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 | + | |
288 | 345 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
293 | 350 | | |
294 | 351 | | |
295 | 352 | | |
296 | 353 | | |
297 | 354 | | |
298 | 355 | | |
299 | 356 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
311 | 376 | | |
312 | 377 | | |
313 | | - | |
314 | | - | |
| 378 | + | |
315 | 379 | | |
316 | 380 | | |
317 | 381 | | |
| |||
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
272 | 275 | | |
273 | 276 | | |
274 | 277 | | |
| |||
299 | 302 | | |
300 | 303 | | |
301 | 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 | + | |
302 | 344 | | |
303 | 345 | | |
304 | 346 | | |
| |||
1410 | 1452 | | |
1411 | 1453 | | |
1412 | 1454 | | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
1413 | 1488 | | |
0 commit comments