aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/http_downloader.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-26 20:04:02 +0900
committernsfisis <nsfisis@gmail.com>2026-05-26 20:04:02 +0900
commitf411daceacad66e0bd774fda7d3c5ef8533cc55c (patch)
treeeefb065e4d676a3f7031ca49bab21c773b00b134 /crates/shirabe/src/util/http_downloader.rs
parent1921f173ea219cb4b25847294d2d3fa465550fbb (diff)
downloadphp-shirabe-f411daceacad66e0bd774fda7d3c5ef8533cc55c.tar.gz
php-shirabe-f411daceacad66e0bd774fda7d3c5ef8533cc55c.tar.zst
php-shirabe-f411daceacad66e0bd774fda7d3c5ef8533cc55c.zip
refactor(io): share IOInterface via Rc<RefCell<dyn _>> handle
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/util/http_downloader.rs')
-rw-r--r--crates/shirabe/src/util/http_downloader.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs
index 77d35b1..610bd3a 100644
--- a/crates/shirabe/src/util/http_downloader.rs
+++ b/crates/shirabe/src/util/http_downloader.rs
@@ -32,7 +32,7 @@ use crate::util::http::Response;
#[derive(Debug)]
pub struct HttpDownloader {
/// @var IOInterface
- io: Box<dyn IOInterface>,
+ io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
/// @var Config
config: std::rc::Rc<std::cell::RefCell<Config>>,
/// @var array<Job>
@@ -103,7 +103,7 @@ impl HttpDownloader {
/// @param Config $config The config
/// @param mixed[] $options The options
pub fn new(
- io: Box<dyn IOInterface>,
+ io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
config: std::rc::Rc<std::cell::RefCell<Config>>,
options: IndexMap<String, PhpMixed>,
disable_tls: bool,
@@ -115,8 +115,7 @@ impl HttpDownloader {
// The cafile option can be set via config.json
let mut self_options: IndexMap<String, PhpMixed> = IndexMap::new();
if disable_tls == false {
- self_options =
- StreamContextFactory::get_tls_defaults(&options, Some(&*io)).unwrap_or_default();
+ self_options = StreamContextFactory::get_tls_defaults(&options, ()).unwrap_or_default();
}
// handle the other externally set options normally.
@@ -124,7 +123,7 @@ impl HttpDownloader {
let curl = if Self::is_curl_enabled() {
Some(CurlDownloader::new(
- io.clone_box(),
+ io.clone(),
config.clone(),
options.clone(),
disable_tls,
@@ -134,7 +133,7 @@ impl HttpDownloader {
};
let rfs = Some(RemoteFilesystem::new(
- io.clone_box(),
+ io.clone(),
config.clone(),
options.clone(),
disable_tls,
@@ -317,7 +316,7 @@ impl HttpDownloader {
)
.unwrap_or(false)
{
- self.io.set_authentication(
+ self.io.borrow_mut().set_authentication(
origin.clone(),
rawurldecode(
m.get(&CaptureKey::ByIndex(1))