zed/crates/extension
Nathan Sobo fc64843dd5
Enhance HTTP API for extensions (#16067)
# HTTP Client Improvements for Extension API

This PR enhances the HTTP client functionality in the Zed extension API,
providing more control over requests and allowing for streaming
responses.

## Key Changes

1. Extended `HttpRequest` struct:
   - Added `method` field to specify HTTP method
   - Added `headers` field for custom headers
   - Added optional `body` field for request payload

2. Introduced `HttpMethod` enum for supported HTTP methods

3. Updated `HttpResponse` struct:
   - Added `headers` field to access response headers
- Changed `body` type from `String` to `Vec<u8>` for binary data support

4. Added streaming support:
   - New `fetch_stream` function to get a response stream
   - Introduced `HttpResponseStream` resource for chunked reading

5. Updated internal implementations to support these new features

6. Modified the Gleam extension to use the new API structure

## Motivation

These changes provide extension developers with more flexibility and
control over HTTP requests. The streaming support is particularly useful
for handling large responses efficiently or ideally streaming into the
UI.

## Testing

- [x] Updated existing tests
- [ ] Added new tests for streaming functionality

## Next Steps

- Consider adding more comprehensive examples in the documentation
- Evaluate performance impact of streaming for large responses

Please review and let me know if any adjustments are needed.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-08-12 10:36:49 -04:00
..
src Enhance HTTP API for extensions (#16067) 2024-08-12 10:36:49 -04:00
build.rs Copy extension_api Rust files to OUT_DIR when building extension to work around rust-analyzer limitation (#16064) 2024-08-10 18:19:11 -06:00
Cargo.toml extension: Upgrade wasmtime to v21 (#15210) 2024-07-25 13:56:40 -04:00
LICENSE-GPL Add logic for managing language and theme extensions (#7467) 2024-02-07 15:14:50 -05:00