本文整理汇总了C++中HttpRequest::SetReferer方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpRequest::SetReferer方法的具体用法?C++ HttpRequest::SetReferer怎么用?C++ HttpRequest::SetReferer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::SetReferer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void jsWindow::load( const string& url )
{
string to_load = url;
string refer = location->url.tostring();
int relocs = 0;
HttpResponse* hresp;
i_response_ptr resp;
while (true) {
HttpRequest* hreq = new HttpRequest(to_load);
hreq->Method(HttpRequest::wemGet);
hreq->depth(relocs);
hreq->SetReferer(refer);
i_request_ptr req(hreq);
resp = browser->http_request(req);
hresp = (HttpResponse*)resp.get();
if (hresp->HttpCode() < 300 || hresp->HttpCode() >= 400) {
break;
}
// process redirects
if (relocs < 5) {
relocs++;
refer = to_load;
string to_load = hresp->Headers().find_first("Location");
if (to_load.empty()) {
break;
}
// delete response
resp.reset();
} // if relocs < 5
// delete request
req.reset();
} // while relocations
if (hresp->HttpCode() < 300) {
boost::shared_ptr<html_document> doc(new html_document());
if(doc) {
doc->ParseData(resp);
// execute scripts
#ifdef V8_DOMSHELL
string source;
assign_document( doc );
size_t i = 0;
for(v8_wrapper::iterator_dfs it = document->begin_dfs(); it != document->end_dfs(); ++it) {
if((*it)->m_tag == HTML_TAG_script && (*it)->m_entity) {
document->v8_wrapper::Registrator<v8_wrapper::jsDocument>::m_data.m_execution_point = *it;
source = (*it)->m_entity->attr("#code");
std::string src_url = (*it)->m_entity->attr("src");
if(src_url != "" && source == "") {
if(src_url.find(':') == -1) {
src_url = refer.substr(0, refer.rfind('/') + 1) + src_url;
}
HttpResponse* hresp_;
i_response_ptr resp_;
while (true) {
HttpRequest* hreq_ = new HttpRequest(src_url);
hreq_->Method(HttpRequest::wemGet);
hreq_->depth(relocs);
hreq_->SetReferer(refer);
i_request_ptr req_(hreq_);
resp_ = browser->http_request(req_);
hresp_ = (HttpResponse*)resp_.get();
if (hresp_->HttpCode() < 300 || hresp_->HttpCode() >= 400) {
break;
}
}
if (hresp_->HttpCode() < 300) {
source.assign((const char*)&resp_->Data()[0], resp_->Data().size());
(*it)->m_entity->attr("#code", source);
}
}
#ifdef _DEBUG
LOG4CXX_TRACE(webEngine::iLogger::GetLogger(), _T("audit_jscript::parse_scripts execute script #") << i++ << "; Source:\n" << source);
#endif
browser->execute_string(source, "", true, true);
}
}
process_events(browser, doc, false);
#endif
}
} else {
LOG4CXX_WARN(webEngine::iLogger::GetLogger(), _T("jsWindow::load the ") << hresp->RealUrl().tostring() << _T(" failed! HTTP code=") << hresp->HttpCode());
}
}