in fs/httpfs/httpfs_v2.cpp [182:213]
ssize_t preadv(const struct iovec* iovec, int iovcnt,
off_t offset) override {
Timeout tmo(m_conn_timeout);
struct stat s;
if (fstat(&s) < 0) LOG_ERROR_RETURN(0, -1, "Failed to get file length");
if (offset >= s.st_size) return 0;
iovector_view view((struct iovec*)iovec, iovcnt);
auto count = std::min(view.sum(), (size_t)(s.st_size - offset));
if (count == 0) return 0;
HTTP_OP op;
send_read_request(op, offset, count, tmo);
if (op.status_code < 0) return -1;
auto ret = op.status_code;
if (ret != 200 && ret != 206) {
if (ret == 401 || ret == 403) {
m_authorized = false;
LOG_ERROR_RETURN(EACCES, -1, "GET not authorized", VALUE(m_url));
}
LOG_ERROR_RETURN(ENOENT, -1, "GET response got unexpected stats ",
VALUE(m_url), VALUE(offset), VALUE(ret));
}
if (update_stat_from_resp(&op) < 0) {
LOG_ERROR_RETURN(ENOENT, -1, "GET response got unexpected header ",
VALUE(m_url), VALUE(offset), VALUE(ret));
}
m_authorized = true;
ret = op.resp.readv(iovec, iovcnt);
if (ret < 0) {
LOG_ERROR("HttpFs: read body failed, ", ERRNO());
}
return ret;
}