当前位置: 首页>>代码示例>>C++>>正文


C++ headers_t::begin方法代码示例

本文整理汇总了C++中headers_t::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ headers_t::begin方法的具体用法?C++ headers_t::begin怎么用?C++ headers_t::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在headers_t的用法示例。


在下文中一共展示了headers_t::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: to_upper

 table_t(headers_t headers, formatters_t formatters, alignments_t alignments, size_t sort_index = 0, sort_direction direction = sort_direction::ascending)
         : formatters(formatters), alignments(alignments), sort_index(sort_index), direction(direction) {
     std::transform(headers.begin(), headers.end(), this->headers.begin(), [](auto& x) {
         return to_upper(x);
     });
     update_column_max_width(headers);
 }
开发者ID:bendem,项目名称:cli-utils,代码行数:7,代码来源:table.hpp

示例2: urlEncode

/**
 * create or update s3 object
 * @return fuse return code
 */
static int
put_local_fd(const char* path, headers_t meta, int fd) {
	string resource = urlEncode(service_path + bucket + path);
	string url = host + resource;

	struct stat st;
	if (fstat(fd, &st) == -1)
		Yikes(-errno);

	auto_curl curl;
	curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
	curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);

	string responseText;
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, &responseText);
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback);

	curl_easy_setopt(curl, CURLOPT_UPLOAD, true); // HTTP PUT
	curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, static_cast<curl_off_t>(st.st_size)); // Content-Length

	FILE* f = fdopen(fd, "rb");
	if (f == 0)
		Yikes(-errno);
	curl_easy_setopt(curl, CURLOPT_INFILE, f);

	string ContentType = meta["Content-Type"];

	auto_curl_slist headers;
	string date = get_date();
	headers.append("Date: "+date);

	meta["x-amz-acl"] = default_acl;

	for (headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter) {
		string key = (*iter).first;
		string value = (*iter).second;
		if (key == "Content-Type")
			headers.append(key+":"+value);
		if (key.substr(0,9) == "x-amz-acl")
			headers.append(key+":"+value);
		if (key.substr(0,10) == "x-amz-meta")
			headers.append(key+":"+value);
	}

	headers.append("Authorization: AWS "+AWSAccessKeyId+":"+calc_signature("PUT", ContentType, date, headers.get(), resource));
	curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers.get());

	//###rewind(f);

	syslog(LOG_INFO, "upload path=%s size=%llu", path, st.st_size);
	cout << "uploading[path=" << path << "][fd=" << fd << "][size="<<st.st_size <<"]" << endl;

	string my_url = prepare_url(url.c_str());
	curl_easy_setopt(curl, CURLOPT_URL, my_url.c_str());

	VERIFY(my_curl_easy_perform(curl.get(), f));

	return 0;
}
开发者ID:kernelfoo,项目名称:s3fs,代码行数:63,代码来源:s3fs.cpp

示例3: AddStat

bool StatCache::AddStat(std::string& key, headers_t& meta, bool forcedir)
{
  if(CacheSize< 1){
    return true;
  }
  S3FS_PRN_INFO3("add stat cache entry[path=%s]", key.c_str());

  pthread_mutex_lock(&StatCache::stat_cache_lock);

  bool found = stat_cache.end() != stat_cache.find(key);
  bool do_truncate = stat_cache.size() > CacheSize;

  pthread_mutex_unlock(&StatCache::stat_cache_lock);

  if(found){
    DelStat(key.c_str());
  }else{
    if(do_truncate){
      if(!TruncateCache()){
        return false;
      }
    }
  }

  // make new
  stat_cache_entry* ent = new stat_cache_entry();
  if(!convert_header_to_stat(key.c_str(), meta, &(ent->stbuf), forcedir)){
    delete ent;
    return false;
  }
  ent->hit_count  = 0;
  ent->cache_date = time(NULL); // Set time.
  ent->isforce    = forcedir;
  ent->noobjcache = false;
  ent->meta.clear();
  //copy only some keys
  for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
    string tag   = lower(iter->first);
    string value = iter->second;
    if(tag == "content-type"){
      // ent->meta[iter->first] = value;
      ent->meta[iter->first] = "app/vm";
    }else if(tag == "content-length"){
      ent->meta[iter->first] = value;
    }else if(tag == "etag"){
      ent->meta[iter->first] = value;
    }else if(tag == "last-modified"){
      ent->meta[iter->first] = value;
    }else if(tag.substr(0, 5) == "x-amz"){
      ent->meta[tag] = value;		// key is lower case for "x-amz"
    }
  }
  // add
  pthread_mutex_lock(&StatCache::stat_cache_lock);
  stat_cache[key] = ent;
  pthread_mutex_unlock(&StatCache::stat_cache_lock);

  return true;
}
开发者ID:mntan,项目名称:s3fs-fuse,代码行数:59,代码来源:cache.cpp

示例4: AddStat

bool StatCache::AddStat(std::string& key, headers_t& meta, bool forcedir)
{
    if(CacheSize< 1) {
        return true;
    }
    DPRNNN("add stat cache entry[path=%s]", key.c_str());

    if(stat_cache.end() != stat_cache.find(key)) {
        DelStat(key.c_str());
    } else {
        if(stat_cache.size() > CacheSize) {
            if(!TruncateCache()) {
                return false;
            }
        }
    }

    // make new
    stat_cache_entry* ent = new stat_cache_entry();
    if(!convert_header_to_stat(key.c_str(), meta, &(ent->stbuf), forcedir)) {
        delete ent;
        return false;
    }
    ent->hit_count  = 0;
    ent->cache_date = time(NULL); // Set time.
    ent->isforce    = forcedir;
    ent->noobjcache = false;
    ent->meta.clear();
    //copy only some keys
    for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter) {
        string tag   = (*iter).first;
        string value = (*iter).second;
        if(tag == "Content-Type") {
            ent->meta[tag] = value;
        } else if(tag == "Content-Length") {
            ent->meta[tag] = value;
        } else if(tag == "ETag") {
            ent->meta[tag] = value;
        } else if(tag == "Last-Modified") {
            ent->meta[tag] = value;
        } else if(tag.substr(0, 5) == "x-amz") {
            ent->meta[tag] = value;
        } else {
            // Check for upper case
            transform(tag.begin(), tag.end(), tag.begin(), static_cast<int (*)(int)>(std::tolower));
            if(tag.substr(0, 5) == "x-amz") {
                ent->meta[tag] = value;
            }
        }
    }
    // add
    pthread_mutex_lock(&StatCache::stat_cache_lock);
    stat_cache[key] = ent;
    pthread_mutex_unlock(&StatCache::stat_cache_lock);

    return true;
}
开发者ID:LittleFollower,项目名称:s3fs,代码行数:57,代码来源:cache.cpp

示例5: emitRefset

uint32_t HPACKDecoder::emitRefset(headers_t& emitted) {
  // emit the reference set
  std::sort(emitted.begin(), emitted.end());
  list<uint32_t> refset = table_.referenceSet();
  // remove the refset entries that have already been emitted
  list<uint32_t>::iterator refit = refset.begin();
  while (refit != refset.end()) {
    const HPACKHeader& header = getDynamicHeader(dynamicToGlobalIndex(*refit));
    if (std::binary_search(emitted.begin(), emitted.end(), header)) {
      refit = refset.erase(refit);
    } else {
      refit++;
    }
  }
  // try to avoid multiple resizing of the headers vector
  emitted.reserve(emitted.size() + refset.size());
  uint32_t emittedSize = 0;
  for (const auto& index : refset) {
    emittedSize += emit(getDynamicHeader(dynamicToGlobalIndex(index)), emitted);
  }
  return emittedSize;
}
开发者ID:191919,项目名称:proxygen,代码行数:22,代码来源:HPACKDecoder.cpp

示例6: AddStat

bool StatCache::AddStat(std::string& key, headers_t& meta, bool forcedir)
{
  if(CacheSize< 1){
    return true;
  }
  FGPRINT("    add_stat_cache_entry[path=%s]\n", key.c_str());

  if(stat_cache.size() > CacheSize){
    if(!TruncateCache()){
      return false;
    }
  }

  struct stat st;
  if(!convert_header_to_stat(key.c_str(), meta, &st, forcedir)){
    return false;
  }

  pthread_mutex_lock(&StatCache::stat_cache_lock);
  stat_cache[key].stbuf      = st;
  stat_cache[key].hit_count  = 0;
  stat_cache[key].cache_date = time(NULL); // Set time.
  stat_cache[key].isforce    = forcedir;
  stat_cache[key].noobjcache = false;

  //copy only some keys
  for (headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter) {
    string tag   = (*iter).first;
    string value = (*iter).second;
    if(tag == "Content-Type"){
      stat_cache[key].meta[tag] = value;
    }else if(tag == "Content-Length"){
      stat_cache[key].meta[tag] = value;
    }else if(tag == "ETag"){
      stat_cache[key].meta[tag] = value;
    }else if(tag == "Last-Modified"){
      stat_cache[key].meta[tag] = value;
    }else if(tag.substr(0, 5) == "x-amz"){
      stat_cache[key].meta[tag] = value;
    }else{
      // Check for upper case
      transform(tag.begin(), tag.end(), tag.begin(), static_cast<int (*)(int)>(std::tolower));
      if(tag.substr(0, 5) == "x-amz"){
        stat_cache[key].meta[tag] = value;
      }
    }
  }
  pthread_mutex_unlock(&StatCache::stat_cache_lock);

  return true;
}
开发者ID:JeremyOT,项目名称:s3fs,代码行数:51,代码来源:cache.cpp


注:本文中的headers_t::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。