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


C++ request类代码示例

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


在下文中一共展示了request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: l

response component_namespace::bind_prefix(
    request const& req
  , error_code& ec
    )
{ // {{{ bind_prefix implementation
    // parameters
    std::string key = req.get_name();
    boost::uint32_t prefix = req.get_locality_id();

    mutex_type::scoped_lock l(mutex_);

    component_id_table_type::left_map::iterator cit = component_ids_.left.find(key)
                                    , cend = component_ids_.left.end();

    // This is the first request, so we use the type counter, and then
    // increment it.
    if (component_ids_.left.find(key) == cend)
    {
        if (HPX_UNLIKELY(!util::insert_checked(component_ids_.left.insert(
                std::make_pair(key, type_counter)), cit)))
        {
            l.unlock();

            HPX_THROWS_IF(ec, lock_error
              , "component_namespace::bind_prefix"
              , "component id table insertion failed due to a locking "
                "error or memory corruption")
            return response();
        }

        // If the insertion succeeded, we need to increment the type
        // counter.
        ++type_counter;
    }
开发者ID:NextGenIntelligence,项目名称:hpx,代码行数:34,代码来源:component_namespace_server.cpp

示例4: setup

grid_renderer<T>::grid_renderer(Map const& m, request const& req, attributes const& vars, T & pixmap, double scale_factor, unsigned offset_x, unsigned offset_y)
    : feature_style_processor<grid_renderer>(m, scale_factor),
      pixmap_(pixmap),
      ras_ptr(new grid_rasterizer),
      common_(m, req, vars, offset_x, offset_y, req.width(), req.height(), scale_factor)
{
    setup(m);
}
开发者ID:gischen,项目名称:mapnik,代码行数:8,代码来源:grid_renderer.cpp

示例5: send_request

 bool client::send_request(request &req, response &resp) {
     if (!stream_->is_open() || stream_->eof() || stream_->fail() || stream_->bad()) return false;
     // Make sure there is no pending data in the last response
     resp.clear();
     req.accept_compressed(auto_decompress_);
     resp.set_auto_decompression(auto_decompress_);
     if(!req.write(*stream_)) return false;
     if (!stream_->is_open() || stream_->eof() || stream_->fail() || stream_->bad()) return false;
     //if (!stream_.is_open()) return false;
     return resp.read(*stream_) && (resp.status_code!=http_status_code::INVALID_STATUS);
 }
开发者ID:asianhawk,项目名称:fibio,代码行数:11,代码来源:client.cpp

示例6: setup

agg_renderer<T0,T1>::agg_renderer(Map const& m, request const& req, attributes const& vars, T0 & pixmap, double scale_factor, unsigned offset_x, unsigned offset_y)
    : feature_style_processor<agg_renderer>(m, scale_factor),
      pixmap_(pixmap),
      internal_buffer_(),
      current_buffer_(&pixmap),
      style_level_compositing_(false),
      ras_ptr(new rasterizer),
      gamma_method_(GAMMA_POWER),
      gamma_(1.0),
      common_(req, vars, offset_x, offset_y, req.width(), req.height(), scale_factor)
{
    setup(m);
}
开发者ID:Jiangyangyang,项目名称:mapnik,代码行数:13,代码来源:agg_renderer.cpp

示例7: CoordTransform

renderer_common::renderer_common(request const &req, unsigned offset_x, unsigned offset_y,
                                 unsigned width, unsigned height, double scale_factor)
   : renderer_common(width, height, scale_factor,
                     CoordTransform(req.width(),req.height(),req.extent(),offset_x,offset_y),
                     std::make_shared<label_collision_detector4>(
                        box2d<double>(-req.buffer_size(), -req.buffer_size(), 
                                      req.width() + req.buffer_size() ,req.height() + req.buffer_size())))
{}
开发者ID:anselmbradford,项目名称:mapnik,代码行数:8,代码来源:renderer_common.cpp

示例8: setup

grid_renderer<T>::grid_renderer(Map const& m, request const& req, T & pixmap, double scale_factor, unsigned offset_x, unsigned offset_y)
    : feature_style_processor<grid_renderer>(m, scale_factor),
      pixmap_(pixmap),
      width_(pixmap_.width()),
      height_(pixmap_.height()),
      scale_factor_(scale_factor),
      // NOTE: can change this to m dims instead of pixmap_ if render-time
      // resolution support is dropped from grid_renderer python interface
      t_(pixmap_.width(),pixmap_.height(),req.extent(),offset_x,offset_y),
      font_engine_(),
      font_manager_(font_engine_),
      detector_(boost::make_shared<label_collision_detector4>(box2d<double>(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))),
      ras_ptr(new grid_rasterizer)
{
    setup(m);
}
开发者ID:Blaxxun,项目名称:mapnik,代码行数:16,代码来源:grid_renderer.cpp

示例9: iterate

// TODO: catch exceptions
response symbol_namespace::iterate(
    request const& req
  , error_code& ec
    )
{ // {{{ iterate implementation
    iterate_names_function_type f = req.get_iterate_names_function();

    std::unique_lock<mutex_type> l(mutex_);

    for (gid_table_type::iterator it = gids_.begin(); it != gids_.end(); ++it)
    {
        std::string key(it->first);
        naming::gid_type gid = *(it->second);

        {
            util::unlock_guard<std::unique_lock<mutex_type> > ul(l);
            f(key, gid);
        }

        // re-locate current entry
        it = gids_.find(key);
    }

    LAGAS_(info) << "symbol_namespace::iterate";

    if (&ec != &throws)
        ec = make_success_code();

    return response(symbol_ns_iterate_names);
} // }}}
开发者ID:7ev3n,项目名称:hpx,代码行数:31,代码来源:symbol_namespace_server.cpp

示例10: request_test

const object request_test(request &req)                                         
{                                                                               
  ::boost::optional<status> stat = req.test();                                  
  if (stat)                                                                     
    return object(*stat);                                                       
  else                                                                          
    return object();                                                            
}      
开发者ID:Adikteev,项目名称:rtbkit-deps,代码行数:8,代码来源:py_request.cpp

示例11: get_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

示例12: recv

 bool recv(request &req) {
     bool ret=false;
     if (bad()) return false;
     if(read_timeout_>std::chrono::seconds(0)) {
         // Set read timeout
         watchdog_timer_->expires_from_now(read_timeout_);
     }
     ret=req.read(stream());
     return ret;
 }
开发者ID:windoze,项目名称:fibio-http,代码行数:10,代码来源:server.cpp

示例13: throw

std::string application::process(request & req, response & res) throw()
{
	unsigned int result_code = 200;
	view_function_t view = get_route(req.verb(), req.path());
	std::string str; // Site response.
	try
	{
		// Check if specified view exists.
		// If not, throw "404" - view does not exists.
		if (!view)
			throw http_error(404);
		// Run view.
		view(req, res);
		// Generated response.
		str = res.stream().str();
	} catch (web::http_error const & e)
	{
		// Change HTTP result.
		result_code = e.error_code();
		// Generated response
		// (before the exception was raised)
		str = res.stream().str();
	} catch (std::exception const & e)
	{
		// We know what does this error (could) mean.
		result_code = 500;
		// Exception description is our response.
		str = e.what();
	} catch (...)
	{
		// We do not have idea what this error means.
		result_code = 500;
	}
	// Construct a valid HTTP response.
	std::stringstream output;
	output << "HTTP/1.1 " << result_code << " OK\r\n"
		"Content-Type:text/html\r\n"
		"Content-Length: " << str.length() <<
		"\r\n\r\n"
		<< str;
	return output.str();
}
开发者ID:maslovw,项目名称:web,代码行数:42,代码来源:application.cpp

示例14: async

    std::future<response> client::send(const request& req_)
    {
        return std::async(std::launch::async, [=]() -> response {
            response res;

            struct addrinfo hints;

            hints.ai_family     = PF_INET;
            hints.ai_socktype   = SOCK_STREAM;
            hints.ai_protocol   = IPPROTO_TCP;
            hints.ai_flags      = 0;

            uv_getaddrinfo_t resolver;

            data_t data;
            data.req    = &req_;
            data.res    = &res;
            data.loop   = uv_loop_new();

            resolver.data = &data;

            int r = uv_getaddrinfo(
                data.loop,
                &resolver,
                onResolved,
                req_.getUrl().getHost().c_str(),
                std::to_string(req_.getUrl().getPort()).c_str(),
                &hints
            );

            if (r)
            {
                throw std::runtime_error(uv_err_name(r));
            }

            uv_run(data.loop, UV_RUN_DEFAULT);

            uv_loop_delete(data.loop);

            return res;
        });
    }
开发者ID:Bulliby,项目名称:Reactive,代码行数:42,代码来源:client.cpp

示例15: setup

agg_renderer<T>::agg_renderer(Map const& m, request const& req, T & pixmap, double scale_factor, unsigned offset_x, unsigned offset_y)
    : feature_style_processor<agg_renderer>(m, scale_factor),
      pixmap_(pixmap),
      internal_buffer_(),
      current_buffer_(&pixmap),
      style_level_compositing_(false),
      width_(pixmap_.width()),
      height_(pixmap_.height()),
      scale_factor_(scale_factor),
      t_(req.width(),req.height(),req.extent(),offset_x,offset_y),
      font_engine_(),
      font_manager_(font_engine_),
      detector_(boost::make_shared<label_collision_detector4>(box2d<double>(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))),
      ras_ptr(new rasterizer),
      query_extent_(),
      gamma_method_(GAMMA_POWER),
      gamma_(1.0)
{
    setup(m);
}
开发者ID:PetrDlouhy,项目名称:mapnik,代码行数:20,代码来源:agg_renderer.cpp


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