本文整理汇总了C++中HttpResponse::getCookies方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpResponse::getCookies方法的具体用法?C++ HttpResponse::getCookies怎么用?C++ HttpResponse::getCookies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::getCookies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSessionId
QByteArray HttpSessionStore::getSessionId(HttpRequest& request, HttpResponse& response) {
// The session ID in the response has priority because this one will be used in the next request.
mutex.lock();
// Get the session ID from the response cookie
QByteArray sessionId=response.getCookies().value(cookieName).getValue();
if (sessionId.isEmpty()) {
// Get the session ID from the request cookie
sessionId=request.getCookie(cookieName);
}
// Clear the session ID if there is no such session in the storage.
if (!sessionId.isEmpty()) {
if (!sessions.contains(sessionId)) {
qDebug("HttpSessionStore: received invalid session cookie with ID %s",sessionId.data());
sessionId.clear();
}
}
mutex.unlock();
return sessionId;
}
示例2: mod_ffeadcpp_method_handler
static int mod_ffeadcpp_method_handler (request_rec *r)
{
string port = CastUtil::lexical_cast<string>(r->server->port);
//signal(SIGSEGV,signalSIGSEGV);
string content;
apr_bucket_brigade *bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
for ( ; ; ) {
apr_bucket* b ;
bool done = false;
ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES, APR_BLOCK_READ, HUGE_STRING_LEN);
for ( b = APR_BRIGADE_FIRST(bb);b != APR_BRIGADE_SENTINEL(bb);b = APR_BUCKET_NEXT(b) )
{
size_t bytes ;
const char* buf = "\0";
if ( APR_BUCKET_IS_EOS(b) )
{
done = true;
}
else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ)== APR_SUCCESS )
{
content += string(buf, 0, bytes);
}
}
if (done)
break;
else
apr_brigade_cleanup(bb) ;
}
apr_brigade_destroy(bb) ;
HttpRequest* hreq= new HttpRequest();
string cntpath = serverRootDirectory + "web/";
string webpath = "URL" + cntpath;
MyReq* req = new MyReq();
req->r = r;
req->htreq = hreq;
apr_table_do(iterate_func, req, r->headers_in, NULL);
ip_address = hreq->getHeader(HttpRequest::Host);
string tipaddr = ip_address;
if(port!="80")
tipaddr += (":" + port);
ConfigurationData::getInstance()->ip_address = tipaddr;
string contret;
if(content!="")
{
contret = hreq->buildRequest("Content",content.c_str());
fprintf(stderr,contret.c_str());
fflush(stderr);
}
hreq->buildRequest(webpath.c_str(),r->uri);
hreq->buildRequest("Method",r->method);
if(r->args != NULL && r->args[0] != '\0')
{
hreq->buildRequest("GetArguments",r->args);
}
hreq->buildRequest("HttpVersion", r->protocol);
HttpResponse respo = service(hreq);
string h1 = respo.generateResponse(hreq->getMethod(), hreq, false);
for (int var = 0; var < (int)respo.getCookies().size(); var++)
{
apr_table_add(r->headers_out, "Set-cookie", respo.getCookies().at(var).c_str());
}
r->status_line = respo.getStatusLine().c_str();
if(respo.getHeader(HttpResponse::ContentType)!="")
{
r->content_type = respo.getHeader(HttpResponse::ContentType).c_str();
}
r->clength = h1.length();
fprintf(stderr,"\n\n\n\n--------------------------------------------\n");
fprintf(stderr,hreq->getUrl().c_str());
fprintf(stderr,"\n");
string star = hreq->toString();
fprintf(stderr,star.c_str());
fprintf(stderr,"\n--------------------------------------------\n");
fprintf(stderr,contret.c_str());
fflush(stderr);
fprintf(stderr,"\n\n");
fprintf(stderr,content.c_str());
fprintf(stderr,"\n");
fprintf(stderr,"ip_address = %s", tipaddr.c_str());
fprintf(stderr,"\n");
fprintf(stderr,"\n--------------------------------------------\n\n\n\n");
fflush(stderr);
fprintf(stderr, h1.c_str());
fflush(stderr);
delete hreq;
delete req;
if(h1!="")
{
//.........这里部分代码省略.........
示例3: ngx_http_ffeadcpp_module_handler_post_read
static ngx_int_t ngx_http_ffeadcpp_module_handler_post_read(ngx_http_request_t *r)
{
string cntpath = "";
cntpath.append(ffeadcpp_path.data, ffeadcpp_path.len);
cntpath += "/web/";
HttpRequest* req = new HttpRequest(cntpath);
//cerr << "FFEAD in ngx_http_ffeadcpp_module_handler " << cntpath << r->uri.data << endl;
ngx_int_t rc;
ngx_buf_t *b;
ngx_chain_t out;
ngx_list_part_t *part;
ngx_table_elt_t *h;
ngx_uint_t i;
/*
Get the first part of the list. There is usual only one part.
*/
part = &r->headers_in.headers.part;
h = part->elts;
/*
Headers list array may consist of more than one part,
so loop through all of it
*/
for (i = 0; /* void */ ; i++) {
if (i >= part->nelts) {
if (part->next == NULL) {
/* The last part, search is done. */
break;
}
part = part->next;
h = part->elts;
i = 0;
}
// cerr << "header -> " << string(h[i].key.data, h[i].key.len) << " = " << string(h[i].value.data, h[i].value.len) << endl;
req->buildRequest(string(h[i].key.data, h[i].key.len), string(h[i].value.data, h[i].value.len));
}
string content;
ngx_http_read_input_data(r, content);
//cerr << "Input Request Data\n " << content << "\n======================\n" << endl;
//cerr << "URL -> " << string(r->uri.data,r->uri.len) << endl;
//cerr << "Method -> " << string(r->main->method_name.data, r->main->method_name.len) << endl;
if(content!="")
{
req->buildRequest("Content", content.c_str());
}
req->buildRequest("URL", string(r->uri.data,r->uri.len));
req->buildRequest("Method", string(r->main->method_name.data, r->main->method_name.len));
if(r->args.len > 0)
{
req->buildRequest("GetArguments", string(r->args.data,r->args.len));
}
req->buildRequest("HttpVersion", CastUtil::lexical_cast<string>(r->http_version));
HttpResponse* respo = new HttpResponse;
ServiceTask* task = new ServiceTask;
task->handle(req, respo);
delete task;
cerr << req->toString() << endl;
if(respo->isDone()) {
for (int var = 0; var < (int)respo->getCookies().size(); var++)
{
set_custom_header_in_headers_out(r, "Set-Cookie", respo->getCookies().at(var));
}
/* allocate a buffer for your response body */
b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
if (b == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
/* attach this buffer to the buffer chain */
out.buf = b;
out.next = NULL;
string data = respo->generateResponse(false);
//cerr << "OUT -> " << data << endl;
map<string,string>::const_iterator it;
for(it=respo->getHeaders().begin();it!=respo->getHeaders().end();it++) {
if(StringUtil::toLowerCopy(it->first)==StringUtil::toLowerCopy(HttpResponse::ContentLength)) {
r->headers_out.content_length_n = CastUtil::lexical_cast<int>(it->second);
} else {
set_custom_header_in_headers_out(r, it->first, it->second);
}
}
//cerr << "done writing headers" << endl;
/* adjust the pointers of the buffer */
b->pos = data.c_str();
b->last = data.length();
b->memory = 1; /* this buffer is in memory */
b->last_buf = 1; /* this is the last buffer in the buffer chain */
/* set the status line */
r->headers_out.status = CastUtil::lexical_cast<int>(respo->getStatusCode());
delete respo;
//.........这里部分代码省略.........