bool HTTP4CLIProtocol::SignalInputData(IOBuffer &buffer) { INFO("HTTP4CLI got data"); //1. Get the HTTP protocol. We are sure is a PT_INBOUND_HTTP //because we return true inside AllowFarProtocol only when type == PT_INBOUND_HTTP InboundHTTPProtocol *pHTTP = (InboundHTTPProtocol *) GetFarProtocol(); //2. Get the request headers Variant headers = pHTTP->GetHeaders(); //3. Populate the input buffer for the next protocol in the stack (PT_INBOUND_JSONCLI) //with the data we just found out inside the headers URI uri; string dummy = "http://localhost" + (string) headers[HTTP_FIRST_LINE][HTTP_URL]; FINEST("dummy: %s", STR(dummy)); if (!URI::FromString(dummy, false, uri)) { FATAL("Invalid request"); return false; } string fullCommand = uri.document(); fullCommand += " "; if (uri.parameters().MapSize() != 0) { fullCommand += unb64(MAP_VAL(uri.parameters().begin())); } fullCommand += "\n"; _localInputBuffer.ReadFromString(fullCommand); //4. Call the next protocol with the new buffer return GetNearProtocol()->SignalInputData(_localInputBuffer); }
bool AppSelectorApplication::IsAuthedSuccess(string uriString) { URI uri; string accessToken; string timeStamp; string clientId; if (SystemManager::IsFactoryMode()) { return true; } URI::FromString(uriString, false, uri); Variant params=uri.parameters(); if (!params.HasKey(URL_CLIENT_ID)) { clientId=(string)SystemManager::GetNVRam("Login"); } else { clientId=(string)params[URL_CLIENT_ID]; } if (params.HasKey(URL_ACCESS_TOKEN)) { accessToken=(string)params[URL_ACCESS_TOKEN]; } if (params.HasKey(URL_TIMESTAMP)) { timeStamp=(string)params[URL_TIMESTAMP]; } DEBUG ("clientId:%s, accessToken:%s, timeStamp:%s", STR(clientId), STR(accessToken), STR(timeStamp)); if (HTTPAuthHelper::IsAuthedSuccess(clientId, accessToken, timeStamp)){ return true; } return false; }