mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Respect allow insecure host in publish (#8440)
This commit is contained in:
parent
614013ed58
commit
e7ae0f50d2
8 changed files with 38 additions and 30 deletions
|
@ -350,16 +350,6 @@ enum Security {
|
|||
}
|
||||
|
||||
impl BaseClient {
|
||||
/// The underlying [`ClientWithMiddleware`] for secure requests.
|
||||
pub fn client(&self) -> ClientWithMiddleware {
|
||||
self.client.clone()
|
||||
}
|
||||
|
||||
/// The underlying [`Client`] without middleware.
|
||||
pub fn raw_client(&self) -> Client {
|
||||
self.raw_client.clone()
|
||||
}
|
||||
|
||||
/// Selects the appropriate client based on the host's trustworthiness.
|
||||
pub fn for_host(&self, url: &Url) -> &ClientWithMiddleware {
|
||||
if self
|
||||
|
|
|
@ -8,8 +8,9 @@ use hyper::service::service_fn;
|
|||
use hyper::{Request, Response};
|
||||
use hyper_util::rt::TokioIo;
|
||||
use insta::{assert_json_snapshot, assert_snapshot, with_settings};
|
||||
use std::str::FromStr;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
use url::Url;
|
||||
use uv_cache::Cache;
|
||||
use uv_client::LineHaul;
|
||||
use uv_client::RegistryClientBuilder;
|
||||
|
@ -53,11 +54,12 @@ async fn test_user_agent_has_version() -> Result<()> {
|
|||
let client = RegistryClientBuilder::new(cache).build();
|
||||
|
||||
// Send request to our dummy server
|
||||
let url = Url::from_str(&format!("http://{addr}"))?;
|
||||
let res = client
|
||||
.cached_client()
|
||||
.uncached()
|
||||
.client()
|
||||
.get(format!("http://{addr}"))
|
||||
.for_host(&url)
|
||||
.get(url)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
|
@ -149,11 +151,12 @@ async fn test_user_agent_has_linehaul() -> Result<()> {
|
|||
let client = builder.build();
|
||||
|
||||
// Send request to our dummy server
|
||||
let url = Url::from_str(&format!("http://{addr}"))?;
|
||||
let res = client
|
||||
.cached_client()
|
||||
.uncached()
|
||||
.client()
|
||||
.get(format!("http://{addr}"))
|
||||
.for_host(&url)
|
||||
.get(url)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue