From 71790a926d73a59f3f8ab5efb6e551a6eacf88b8 Mon Sep 17 00:00:00 2001 From: Coldwings Date: Sun, 18 Feb 2024 11:19:52 +0800 Subject: [PATCH] FIX httpfs_v2 common header for file able to replace by ioctl (#351) FIX httpfs common header for file able to replace by ioctl --- fs/httpfs/httpfs_v2.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/httpfs/httpfs_v2.cpp b/fs/httpfs/httpfs_v2.cpp index e12f2a8c..57e07072 100644 --- a/fs/httpfs/httpfs_v2.cpp +++ b/fs/httpfs/httpfs_v2.cpp @@ -103,7 +103,7 @@ class HttpFs_v2 : public fs::IFileSystem { class HttpFile_v2 : public fs::VirtualReadOnlyFile { public: std::string m_url; - net::http::CommonHeaders<> m_common_header; + unordered_map_string_key m_common_header; HttpFs_v2* m_fs; struct stat m_stat; uint64_t m_stat_gettime = 0; @@ -153,7 +153,8 @@ class HttpFile_v2 : public fs::VirtualReadOnlyFile { url.appends(m_url, "?", m_url_param); op.set_enable_proxy(m_fs->get_client()->has_proxy()); op.req.reset(net::http::Verb::GET, url, op.enable_proxy); - op.req.headers.merge(m_common_header); + for (auto &kv : m_common_header) + op.req.headers.insert(kv.first, kv.second); op.req.headers.range(offset, offset + length - 1); op.req.headers.content_length(0); op.timeout = tmo.timeout(); @@ -228,11 +229,10 @@ class HttpFile_v2 : public fs::VirtualReadOnlyFile { return m_exists ? 0 : -1; } - //TODO: 这里是否需要考虑m_common_header被打爆的问题? void add_header(va_list args) { auto k = va_arg(args, const char*); auto v = va_arg(args, const char*); - m_common_header.insert(k, v); + m_common_header[k] = v; } void add_url_param(va_list args) { m_url_param = va_arg(args, const char*); }