本文整理汇总了C++中request类的典型用法代码示例。如果您正苦于以下问题:C++ request类的具体用法?C++ request怎么用?C++ request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了request类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: resolve_id
response component_namespace::resolve_id(
request const& req
, error_code& ec
)
{ // {{{ resolve_id implementation
// parameters
component_id_type key = req.get_component_type();
// If the requested component type is a derived type, use only its derived
// part for the lookup.
if (key != components::get_base_type(key))
key = components::get_derived_type(key);
std::lock_guard<mutex_type> l(mutex_);
factory_table_type::const_iterator it = factories_.find(key)
, end = factories_.end();
// REVIEW: Should we differentiate between these two cases? Should we
// throw an exception if it->second.empty()? It should be impossible.
if (it == end || it->second.empty())
{
LAGAS_(info) << (boost::format(
"component_namespace::resolve_id, key(%1%), localities(0)")
% key);
if (&ec != &throws)
ec = make_success_code();
return response(component_ns_resolve_id
, std::vector<boost::uint32_t>());
}
else
{
std::vector<boost::uint32_t> p;
prefixes_type const& prefixes = it->second;
prefixes_type::const_iterator pit = prefixes.begin()
, pend = prefixes.end();
for (; pit != pend; ++pit)
p.push_back(*pit);
LAGAS_(info) << (boost::format(
"component_namespace::resolve_id, key(%1%), localities(%2%)")
% key % prefixes.size());
if (&ec != &throws)
ec = make_success_code();
return response(component_ns_resolve_id, p);
}
} // }}}
开发者ID:jyzhang-bjtu,项目名称:hpx,代码行数:54,代码来源:component_namespace_server.cpp
示例17: _handler
fetcher_handler::fetcher_handler(const request &req, handler *h)
: _handler(h)
{
_recv_mb = new ACE_Message_Block(_max_response_size);
// Create the message to send
ACE_Message_Block *hdr_mb = new ACE_Message_Block(_max_header_size);
// GET file HTTP/1.1
// Connection: close
//
int n;
n = ACE_OS::snprintf(hdr_mb->wr_ptr(), hdr_mb->space(),
"%s %s HTTP/1.0\r\n",
req.method().c_str(),
req.target_url().file().c_str());
if (n > 0) hdr_mb->wr_ptr(n);
n = ACE_OS::snprintf(hdr_mb->wr_ptr(), hdr_mb->space(),
"Host: %s\r\n" \
"Connection: close\r\n\r\n",
req.target_url().host().c_str());
if (n > 0) hdr_mb->wr_ptr(n);
if (hdr_mb->space()) {
*(hdr_mb->wr_ptr()) = 0;
ACE_DEBUG((LM_DEBUG, "Writing HTTP request\n",
hdr_mb->base()));
// ACE_DEBUG((LM_DEBUG, "Writing HTTP request:\n%s",
// hdr_mb->base()));
} else {
throw exceptionf(0, "Not enough space in buffer of size %d for HTTP header",
_max_header_size);
}
this->putq(hdr_mb);
}
开发者ID:ajalkane,项目名称:rvhouse,代码行数:36,代码来源:fetcher_handler.cpp
示例18: addNewReq
void IOQ_SCAN::addNewReq(request req){ //used for FSCAN
int size = addedQ.size();
//insert the new request in order of track #
if(addedQ.empty())
addedQ.push_back(req);
else{
int i = 0;
for(; i < size; i++){
if(addedQ[i].getTrackNum() > req.getTrackNum())
break;
}
addedQ.insert(addedQ.begin() + i, req);
}
//cout << timer << ": " << req.getIndex() << " add " << req.getTrackNum() << endl;
}
开发者ID:hj690,项目名称:OS_Lab,代码行数:17,代码来源:IOQ.cpp
示例19: 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
示例20: bind_name
response component_namespace::bind_name(
request const& req
, error_code& ec
)
{ // {{{ bind_name implementation
// parameters
std::string key = req.get_name();
std::unique_lock<mutex_type> l(mutex_);
component_id_table_type::left_map::iterator it = component_ids_.left.find(key)
, end = component_ids_.left.end();
// If the name is not in the table, register it (this is only done so
// we can implement a backwards compatible get_component_id).
if (it == end)
{
if (HPX_UNLIKELY(!util::insert_checked(component_ids_.left.insert(
std::make_pair(key, type_counter)), it)))
{
l.unlock();
HPX_THROWS_IF(ec, lock_error
, "component_namespace::bind_name"
, "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;
}
LAGAS_(info) << (boost::format(
"component_namespace::bind_name, key(%1%), ctype(%2%)")
% key % it->second);
if (&ec != &throws)
ec = make_success_code();
return response(component_ns_bind_name, it->second);
} // }}}
开发者ID:jyzhang-bjtu,项目名称:hpx,代码行数:43,代码来源:component_namespace_server.cpp
注:本文中的request类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论