Skip to content

Commit

Permalink
FIX httpfs_v2 common header for file able to replace by ioctl (alibab…
Browse files Browse the repository at this point in the history
…a#351)

FIX httpfs common header for file able to replace by ioctl
  • Loading branch information
Coldwings authored and beef9999 committed Feb 18, 2024
1 parent 1417a40 commit 71790a9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/httpfs/httpfs_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> m_common_header;
HttpFs_v2* m_fs;
struct stat m_stat;
uint64_t m_stat_gettime = 0;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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*); }
Expand Down

0 comments on commit 71790a9

Please sign in to comment.