本文整理汇总了C++中HttpRequest类的典型用法代码示例。如果您正苦于以下问题:C++ HttpRequest类的具体用法?C++ HttpRequest怎么用?C++ HttpRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HttpRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isMyRequest
bool FileDeleteHandler::isMyRequest(HttpRequest &hmsg){
// DELETE /files/'username'/'filename' quiere decir borrar archivo de tal usuario
Server_Logger* log = Server_Logger::getInstance();
log->Log("Verifica que se trate de un Handler tipo FileDelete",INFO);
if(hmsg.getUriParsedByIndex(0) == HttpRequest::FILES &&
hmsg.getUriCantCampos() == 3 &&
hmsg.getUriType() == HttpRequest::ELEMENT_URI &&
hmsg.getMethod() == HttpRequest::DELETE){
log->Log("Confirma que es un Handler tipo FileDelete",INFO);
return true;
}
return false;
}
示例2: isMyRequest
bool SignUpHandler::isMyRequest(HttpRequest &hmsg){
// POST /users/ quiere decir sign up
Server_Logger* log = Server_Logger::getInstance();
log->Log("Verifica que se trate de un Handler tipo SignUp",INFO);
if(hmsg.getUriParsedByIndex(0) == HttpRequest::USERS &&
hmsg.getUriCantCampos() == 1 &&
hmsg.getUriType() == HttpRequest::COLLECTION_URI &&
hmsg.getMethod() == HttpRequest::POST){
log->Log("Confirma que es un Handler tipo SignUp",INFO);
return true;
}
return false;
}
示例3: isMyRequest
bool UserModifyHandler::isMyRequest(HttpRequest &hmsg){
// PUT /users/'username' quiere decir modificar perfil de tal usuario
Server_Logger* log = Server_Logger::getInstance();
log->Log("Verifica que se trate de un Handler tipo UserModify",INFO);
if(hmsg.getUriParsedByIndex(0) == HttpRequest::USERS &&
hmsg.getUriCantCampos() == 2 &&
hmsg.getUriType() == HttpRequest::ELEMENT_URI &&
hmsg.getMethod() == HttpRequest::PUT){
log->Log("Confirma que es un Handler tipo UserModify",INFO);
return true;
}
return false;
}
示例4: isMyRequest
bool FileAddHandler::isMyRequest(HttpRequest &hmsg){
// POST /files/'username'/ quiere decir subir archivo de tal usuario
Server_Logger* log = Server_Logger::getInstance();
log->Log("Verifica que se trate de un Handler tipo FileAdd",INFO);
if(hmsg.getUriParsedByIndex(0) == HttpRequest::FILES &&
hmsg.getUriCantCampos() == 2 &&
hmsg.getUriType() == HttpRequest::COLLECTION_URI &&
hmsg.getMethod() == HttpRequest::POST){
log->Log("Confirma que es un Handler tipo FileAdd",INFO);
return true;
}
return false;
}
示例5: isMyRequest
bool RecyclebinGetHandler::isMyRequest(HttpRequest &hmsg){
// GET /files/'username'/recycle_bin/ devuelve los archivos de la recycle bin del usuario
Server_Logger* log = Server_Logger::getInstance();
log->Log("Verifica que se trate de un Handler tipo RecycleBinGet",INFO);
if (hmsg.getUriParsedByIndex(0) == HttpRequest::FILES &&
hmsg.getUriCantCampos() == 3 &&
hmsg.getUriParsedByIndex(2) == HttpRequest::RECYCLE_BIN &&
hmsg.getMethod() == HttpRequest::GET){
log->Log("Confirma que es un Handler tipo RecycleBinGet",INFO);
return true;
}
return false;
}
示例6: HttpRequest
HttpRequest *
HttpRequest::CreateRequest(const wchar_t * target,
Method method,
HttpRequestStatusListener * listener)
{
HttpRequest * req = PNEW HttpRequest(target, method, listener);
req->Hold(); // One hold for TaskRunner()
req->m_task = task_create(NULL, 0, TaskRunner, req, NULL, 0);
return req; // Leave held. Caller should release
// the request.
}
示例7: process
bool_t BtceBtcUsd::process(Callback& callback)
{
HttpRequest httpRequest;
Buffer data;
String dataStr;
for(;; Thread::sleep(14000))
{
String url("https://btc-e.com/api/2/btc_usd/trades");
if(!httpRequest.get(url, data))
{
error = httpRequest.getErrorString();
open = false;
return false;
}
dataStr.attach((const char_t*)(byte_t*)data, data.size());
Variant dataVar;
if(!Json::parse(dataStr, dataVar))
{
error = "Could not parse trade data.";
open = false;
return false;
}
const List<Variant>& tradesList = dataVar.toList();
Trade trade;
if(!tradesList.isEmpty())
{
for(List<Variant>::Iterator i = --List<Variant>::Iterator(tradesList.end()), begin = tradesList.begin();; --i)
{
const HashMap<String, Variant>& tradeData = i->toMap();
trade.id = tradeData.find("tid")->toInt64();
int64_t timestamp = tradeData.find("date")->toInt64();
trade.time = timestamp * 1000LL;
trade.price = tradeData.find("price")->toDouble();
trade.amount = tradeData.find("amount")->toDouble();
trade.flags = 0;
if(trade.id > lastTradeId)
{
if(!callback.receivedTrade(trade))
return false;
lastTradeId = trade.id;
}
if(i == begin)
break;
}
}
}
return false; // unreachable
}
示例8: HttpRequest
// 发送HTTP请求
void HelloWorld::onHttpRequest(std::string type)
{
// 创建HTTP请求
HttpRequest* request = new HttpRequest();
if (type == "get")
{
request->setRequestType(HttpRequest::Type::GET);
// url后面附加数据信息
request->setUrl("http://httpbin.org/get?name=hello&pwd=world");
}
else if(type == "post")
{
request->setRequestType(HttpRequest::Type::POST);
request->setUrl("http://httpbin.org/post");
// 设置post发送请求的数据信息
std::string data = "hello world!";
request->setRequestData(data.c_str(), data.length());
}
// HTTP响应函数
request->setResponseCallback(CC_CALLBACK_2(HelloWorld::onHttpResponse, this));
// 发送请求
HttpClient::getInstance()->send(request);
// 释放链接
request->release();
}
示例9: onHttpRequestContentCompleted
virtual void onHttpRequestContentCompleted(HttpRequest & request, AutoRef<DataSink> sink, HttpResponse & response) {
cout << " ** path : " << request.getHeader().getPart2() << endl;
if (request.getPath() == "/device.xml") {
response.setStatus(200);
response.setContentType("text/xml");
setFixedTransfer(response, dd(_udn));
} else if (request.getHeader().getPart2() == "/scpd.xml?udn=" + _udn + "&serviceType=" + dummy) {
response.setStatus(200);
response.setContentType("text/xml");
setFixedTransfer(response, scpd());
} else {
response.setStatus(404);
}
}
示例10: _check_permission
void EventHandlerChecksAuthentication::_check_permission(HttpRequest &hmsg){
std::string username = hmsg.getUsername();
std::string token = hmsg.getConnToken();
Server_Logger* log = Server_Logger::getInstance();
log->Log("Se recibe la httprequest y se verifica token",INFO);
log->Log("El username de la request es : "+username,DEBUG);
log->Log("El token de la request es : "+username,DEBUG);
// ver si no existen los campos (va, va a fallar la autenticacion si no)
if(this->auth->isValidToken(username, token)){
this->_handle(hmsg);
} else {
hmsg.setResponse(Status::IOError("la token de autenticacion provista no es correcta"));
}
}
示例11: FileLog
void HttpRequestManager::StopAllRequest() {
FileLog("httprequest", "HttpRequestManager::StopAllRequest()");
HttpRequest *request = NULL;
mKMutex.lock();
for(HttpRequestMap::iterator itr = mHttpRequestMap.begin(); itr != mHttpRequestMap.end(); itr++) {
request = itr->second;
if( request != NULL ) {
request->StopRequest();
}
}
mKMutex.unlock();
}
示例12: _handle
void UserModifyHandler::_handle(HttpRequest &hmsg){
Status s;
Server_Logger* log = Server_Logger::getInstance();
std::string username = hmsg.getUsername();
log->Log("El campo recibido por username es : "+username,DEBUG);
if(username == ""){
hmsg.setResponse(Status::InvalidArgument());
return;
}
std::string email = hmsg.getCampo("email");
log->Log("El campo recibido por email es : "+email,DEBUG);
std::string picture = hmsg.getCampo("picture");
log->Log("El campo recibido por picture es : "+picture,DEBUG);
std::string place = hmsg.getCampo("place");
log->Log("El campo recibido por place es : "+place,DEBUG);
std::string name = hmsg.getCampo("name");
log->Log("El campo recibido por name es : "+name,DEBUG);
UserMetadata user_metadata(db);
user_metadata.setUsername(username);
// tal vez cambiar a ModifyUser como con los archivos
s = user_metadata.DBchange_email(email);
if (s.ok()) s = user_metadata.DBchange_profile_pic(picture);
if (s.ok()) s = user_metadata.DBchange_last_place(place);
if (s.ok()) s = user_metadata.DBchange_name(name);
// ver status
if(s.ok()){
hmsg.setResponse(s, "Changes saved");
} else {
hmsg.setResponse(s);
}
}
示例13: CanonicalizeRequestSigningString
static Aws::String CanonicalizeRequestSigningString(HttpRequest& request, bool urlEscapePath)
{
request.CanonicalizeRequest();
Aws::StringStream signingStringStream;
signingStringStream << HttpMethodMapper::GetNameForHttpMethod(request.GetMethod());
//double encode paths unless explicitly stated otherwise (for s3 compatibility)
URI uriCpy = request.GetUri();
uriCpy.SetPath(uriCpy.GetURLEncodedPath());
signingStringStream << NEWLINE << (urlEscapePath ? uriCpy.GetURLEncodedPath() : uriCpy.GetPath()) << NEWLINE;
if (request.GetQueryString().size() > 1 && request.GetQueryString().find("=") != std::string::npos)
{
signingStringStream << request.GetQueryString().substr(1) << NEWLINE;
}
else if (request.GetQueryString().size() > 1)
{
signingStringStream << request.GetQueryString().substr(1) << "=" << NEWLINE;
}
else
{
signingStringStream << NEWLINE;
}
return signingStringStream.str();
}
示例14: AppLogDebug
void
Network::IsReachable(const String& hostAddr) {
String* pProxyAddr = null;
//String hostAddr = L"http://localhost:port";
AppLogDebug("Trying to reach...%S", hostAddr.GetPointer());
__pHttpSession = new HttpSession();
__pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr, hostAddr, null);
HttpTransaction* pHttpTransaction = __pHttpSession->OpenTransactionN();
pHttpTransaction->AddHttpTransactionListener(*this);
HttpRequest* pHttpRequest = pHttpTransaction->GetRequest();
pHttpRequest->SetMethod(NET_HTTP_METHOD_GET);
pHttpRequest->SetUri(hostAddr);
pHttpTransaction->Submit();
}
示例15: UnwrapRequest
void JsHttpRequestProcessor::GetPath(Local<String> name,
const PropertyCallbackInfo<Value>& info) {
// Extract the C++ request object from the JavaScript wrapper.
HttpRequest* request = UnwrapRequest(info.Holder());
// Fetch the path.
const string& path = request->Path();
// Wrap the result in a JavaScript string and return it.
info.GetReturnValue().Set(
String::NewFromUtf8(info.GetIsolate(), path.c_str(),
NewStringType::kNormal,
static_cast<int>(path.length())).ToLocalChecked());
}