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


C++ request::get_param方法代码示例

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


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

示例1: get_request_path

std::string get_request_path(request &req) {
  const char *request_uri = req.get_param("REQUEST_URI");

  if ((request_uri == NULL) || (strlen(request_uri) == 0)) {
    // fall back to PATH_INFO if REQUEST_URI isn't available.
    // the former is set by fcgi, the latter by Rack.
    request_uri = req.get_param("PATH_INFO");
  }

  if ((request_uri == NULL) || (strlen(request_uri) == 0)) {
    ostringstream ostr;
    ostr << "request didn't set either the $REQUEST_URI or $PATH_INFO "
            "environment variables.";
    throw http::server_error(ostr.str());
  }

  const char *request_uri_end = request_uri + strlen(request_uri);
  // i think the only valid position for the '?' char is at the beginning
  // of the query string.
  const char *question_mark = std::find(request_uri, request_uri_end, '?');
  if (question_mark == request_uri_end) {
    return string(request_uri);
  } else {
    return string(request_uri, question_mark);
  }
}
开发者ID:woodpeck,项目名称:openstreetmap-cgimap,代码行数:26,代码来源:request_helpers.cpp

示例2: get_query_string

string get_query_string(request &req) {
  // try the query string that's supposed to be present first
  const char *query_string = req.get_param("QUERY_STRING");

  // if that isn't present, then this may be being invoked as part of a
  // 404 handler, so look at the request uri instead.
  if (query_string == NULL) {
    const char *request_uri = req.get_param("REQUEST_URI");

    if ((request_uri == NULL) || (strlen(request_uri) == 0)) {
      // fail. something has obviously gone massively wrong.
      ostringstream ostr;
      ostr << "request didn't set the $QUERY_STRING or $REQUEST_URI "
           << "environment variables.";
      throw http::server_error(ostr.str());
    }

    const char *request_uri_end = request_uri + strlen(request_uri);
    // i think the only valid position for the '?' char is at the beginning
    // of the query string.
    const char *question_mark = std::find(request_uri, request_uri_end, '?');
    if (question_mark == request_uri_end) {
      return string();
    } else {
      return string(question_mark + 1);
    }

  } else {
    return string(query_string);
  }
}
开发者ID:woodpeck,项目名称:openstreetmap-cgimap,代码行数:31,代码来源:request_helpers.cpp

示例3: choose_encoding

/**
 * get encoding to use for response.
 */
boost::shared_ptr<http::encoding> get_encoding(request &req) {
  const char *accept_encoding = req.get_param("HTTP_ACCEPT_ENCODING");

  if (accept_encoding) {
    return http::choose_encoding(string(accept_encoding));
  } else {
    return boost::shared_ptr<http::identity>(new http::identity());
  }
}
开发者ID:woodpeck,项目名称:openstreetmap-cgimap,代码行数:12,代码来源:request_helpers.cpp

示例4: fcgi_get_env

string fcgi_get_env(request &req, const char *name, const char *default_value) {
  assert(name);
  const char *v = req.get_param(name);

  // since the map script is so simple i'm just going to assume that
  // any time we fail to get an environment variable is a fatal error.
  if (v == NULL) {
    if (default_value) {
      v = default_value;
    } else {
      ostringstream ostr;
      ostr << "request didn't set the $" << name << " environment variable.";
      throw http::server_error(ostr.str());
    }
  }

  return string(v);
}
开发者ID:woodpeck,项目名称:openstreetmap-cgimap,代码行数:18,代码来源:request_helpers.cpp


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