Allow extensions to control the redirect policy for the HTTP client (#16162)

This PR extends the extension API with support for controlling the
redirect policy used by the HTTP client.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-08-13 10:40:21 -04:00 committed by GitHub
parent 98a2ab0686
commit 4450ebff6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 42 additions and 14 deletions

View file

@ -4,7 +4,8 @@ use std::{fs, io};
use zed::lsp::CompletionKind;
use zed::{
CodeLabel, CodeLabelSpan, HttpMethod, HttpRequest, KeyValueStore, LanguageServerId,
SlashCommand, SlashCommandArgumentCompletion, SlashCommandOutput, SlashCommandOutputSection,
RedirectPolicy, SlashCommand, SlashCommandArgumentCompletion, SlashCommandOutput,
SlashCommandOutputSection,
};
use zed_extension_api::{self as zed, Result};
@ -208,6 +209,7 @@ impl zed::Extension for GleamExtension {
"Zed (Gleam Extension)".to_string(),
)],
body: None,
redirect_policy: RedirectPolicy::FollowAll,
})?;
let (markdown, _modules) =

View file

@ -10,7 +10,9 @@ use html_to_markdown::{
convert_html_to_markdown, HandleTag, HandlerOutcome, HtmlElement, MarkdownWriter,
StartTagOutcome, TagHandler,
};
use zed_extension_api::{self as zed, HttpMethod, HttpRequest, KeyValueStore, Result};
use zed_extension_api::{
self as zed, HttpMethod, HttpRequest, KeyValueStore, RedirectPolicy, Result,
};
pub fn index(package: String, database: &KeyValueStore) -> Result<()> {
let headers = vec![(
@ -23,6 +25,7 @@ pub fn index(package: String, database: &KeyValueStore) -> Result<()> {
url: format!("https://hexdocs.pm/{package}"),
headers: headers.clone(),
body: None,
redirect_policy: RedirectPolicy::FollowAll,
})?;
let (package_root_markdown, modules) =
@ -36,6 +39,7 @@ pub fn index(package: String, database: &KeyValueStore) -> Result<()> {
url: format!("https://hexdocs.pm/{package}/{module}.html"),
headers: headers.clone(),
body: None,
redirect_policy: RedirectPolicy::FollowAll,
})?;
let (markdown, _modules) =