Bruce Weirdan
2ced9e4d19
Add multipart/form-data uploads (#13532)
Fixes nushell/nushell#11046
# Description
This adds support for `multipart/form-data` (RFC 7578) uploads to
nushell.
Binary data is uploaded as files (`application/octet-stream`),
everything else is uploaded as plain text.
```console
$ http post https://echo.free.beeceptor.com --content-type multipart/form-data {cargo: (open -r Cargo.toml | into binary ), description: "It's some TOML"} | upsert ip "<redacted>"
╭───────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ method │ POST │
│ protocol │ https │
│ host │ echo.free.beeceptor.com │
│ path │ / │
│ ip │ <redacted> │
│ │ ╭─────────────────┬────────────────────────────────────────────────────────────────────╮ │
│ headers │ │ Host │ echo.free.beeceptor.com │ │
│ │ │ User-Agent │ nushell │ │
│ │ │ Content-Length │ 9453 │ │
│ │ │ Accept │ */* │ │
│ │ │ Accept-Encoding │ gzip │ │
│ │ │ Content-Type │ multipart/form-data; boundary=a15f6a14-5768-4a6a-b3a4-686a112d9e27 │ │
│ │ ╰─────────────────┴────────────────────────────────────────────────────────────────────╯ │
│ parsedQueryParams │ {record 0 fields} │
│ │ ╭─────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ parsedBody │ │ │ ╭─────────────┬────────────────╮ │ │
│ │ │ textFields │ │ description │ It's some TOML │ │ │
│ │ │ │ ╰─────────────┴────────────────╯ │ │
│ │ │ │ ╭───┬───────┬──────────┬──────────────────────────┬───────────────────────────┬───────────────────────────────────────────┬────────────────╮ │ │
│ │ │ files │ │ # │ name │ fileName │ Content-Type │ Content-Transfer-Encoding │ Content-Disposition │ Content-Length │ │ │
│ │ │ │ ├───┼───────┼──────────┼──────────────────────────┼───────────────────────────┼───────────────────────────────────────────┼────────────────┤ │ │
│ │ │ │ │ 0 │ cargo │ cargo │ application/octet-stream │ binary │ form-data; name="cargo"; filename="cargo" │ 9101 │ │ │
│ │ │ │ ╰───┴───────┴──────────┴──────────────────────────┴───────────────────────────┴───────────────────────────────────────────┴────────────────╯ │ │
│ │ ╰─────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰───────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
# User-Facing Changes
`http post --content-type multipart/form-data` now accepts a record
which is uploaded as `multipart/form-data`.
Binary data is uploaded as files (`application/octet-stream`),
everything else is uploaded as plain text.
Previously `http post --content-type multipart/form-data` rejected
records, so there's no BC break.
# Tests + Formatting
Added.
# After Submitting
- [ ] update docs to showcase new functionality
2024-08-06 15:28:38 -05:00
..
2023-12-07 05:46:37 +08:00
2024-05-20 00:35:32 +00:00
2024-07-05 21:10:41 +00:00
2024-08-03 10:09:13 +02:00
2024-02-20 11:08:49 -06:00
2024-04-10 13:31:29 +00:00
2024-05-04 15:56:16 +03:00
2024-03-20 22:14:31 +01:00
2024-08-03 10:09:13 +02:00
2024-08-06 15:28:38 -05:00
2024-08-03 10:09:13 +02:00
2024-02-15 06:55:21 +08:00
2022-11-22 16:58:11 -08:00
2024-07-31 20:37:40 +02:00
2024-05-20 00:35:32 +00:00
2024-06-18 07:19:13 -05:00
2024-05-20 00:35:32 +00:00
2024-01-31 16:52:23 -06:00
2024-05-04 00:53:15 +00:00
2024-05-23 02:05:27 +00:00
2024-05-23 02:05:27 +00:00
2023-04-07 14:09:55 -07:00
2024-07-19 00:21:02 -07:00
2024-06-22 07:41:29 -05:00
2024-08-03 10:09:13 +02:00
2024-07-16 03:49:00 +00:00
2023-11-29 23:21:34 +01:00
2024-07-30 18:55:22 -05:00
2023-09-25 08:00:59 -05:00
2023-09-25 08:00:59 -05:00
2023-04-07 14:09:55 -07:00
2023-10-24 12:48:05 -05:00
2024-01-25 14:16:49 +08:00
2024-07-16 03:54:24 +00:00
2024-06-18 07:19:13 -05:00
2024-05-17 00:03:13 +00:00
2023-11-09 13:51:46 +01:00
2024-05-04 00:53:15 +00:00
2024-07-19 00:21:02 -07:00
2023-09-13 06:35:01 +12:00
2023-04-07 14:09:55 -07:00
2024-06-18 21:37:24 -07:00
2024-05-04 00:53:15 +00:00
2024-04-10 06:27:46 +08:00
2023-05-17 18:55:26 -05:00
2023-05-17 18:55:26 -05:00
2024-03-26 17:50:36 +01:00
2024-06-27 09:46:10 -05:00
2024-05-20 00:35:32 +00:00
2023-11-29 23:21:34 +01:00
2023-09-13 06:35:01 +12:00
2024-06-09 12:15:53 +03:00
2024-07-19 00:22:28 -07:00
2024-05-04 00:53:15 +00:00
2024-05-04 00:53:15 +00:00
2024-04-26 06:33:00 -05:00
2024-04-16 21:52:21 +02:00
2023-07-21 17:32:37 +02:00
2024-05-04 00:53:15 +00:00
2023-11-29 23:21:34 +01:00
2024-03-08 02:18:26 -05:00
2024-05-03 08:36:10 +08:00
2023-05-22 13:54:04 -05:00
2024-04-10 06:27:46 +08:00
2023-07-23 20:14:51 +02:00
2024-06-10 10:43:17 +08:00
2024-02-27 15:05:26 +00:00
2023-05-17 18:55:26 -05:00
2024-05-20 00:35:32 +00:00
2024-06-22 07:41:29 -05:00
2024-07-30 18:55:22 -05:00
2023-08-09 14:12:58 +02:00
2023-09-13 06:35:01 +12:00
2024-05-06 14:01:32 +08:00
2024-02-08 07:22:42 +08:00
2023-11-29 23:21:34 +01:00
2024-08-03 10:09:13 +02:00
2024-07-19 04:16:09 +00:00
2024-05-02 09:36:37 -04:00
2024-05-04 00:53:15 +00:00
2024-08-06 11:36:24 +02:00
2023-07-21 17:32:37 +02:00
2024-05-04 00:53:15 +00:00
2024-05-04 00:53:15 +00:00
2023-07-17 18:43:51 +02:00
2024-05-04 00:53:15 +00:00
2024-07-17 16:02:42 -05:00
2024-04-16 19:08:58 +08:00
2024-02-15 07:49:48 -06:00
2023-11-29 23:21:34 +01:00
2024-04-10 06:27:46 +08:00
2023-07-17 18:43:51 +02:00
2024-08-03 10:09:13 +02:00
2023-07-21 17:32:37 +02:00
2024-02-03 13:23:16 +02:00
2024-07-16 07:16:26 -05:00
2024-07-31 18:19:35 +02:00
2024-07-13 16:54:34 +02:00
2023-04-28 13:25:44 +02:00
2023-04-28 13:25:44 +02:00
2024-02-17 10:51:20 +02:00
2023-04-28 13:25:44 +02:00
2024-03-20 22:14:31 +01:00
2023-07-21 17:32:37 +02:00
2024-07-12 02:43:10 +00:00
2024-05-04 00:53:15 +00:00
2024-05-04 00:53:15 +00:00
2024-05-04 00:53:15 +00:00
2024-07-30 18:55:22 -05:00
2024-02-28 17:08:31 -06:00
2023-11-21 20:48:39 -06:00
2022-12-22 16:38:07 -08:00
2024-08-03 10:09:13 +02:00
2023-04-28 13:25:44 +02:00
2024-04-26 16:35:08 +00:00
2024-08-03 10:09:13 +02:00
2024-02-17 20:04:59 +01:00
2024-08-03 10:09:13 +02:00
2024-03-25 16:51:50 -05:00
2023-11-29 23:21:34 +01:00
2023-11-29 23:21:34 +01:00
2024-05-03 08:36:10 +08:00
2024-05-03 08:36:10 +08:00
2024-07-12 02:43:10 +00:00
2024-03-11 19:46:04 +01:00
2023-07-20 19:10:53 -05:00
2023-09-13 06:35:01 +12:00
2024-07-19 04:16:09 +00:00
2024-04-16 19:08:58 +08:00
2023-11-29 23:21:34 +01:00
2024-05-04 00:53:15 +00:00