void v0::Request::HandleContent( const std::string & url, const mf::http::Headers & headers, const std::string & content) { assert( callback_ ); if ( ! callback_ ) return; ResponseType response; response.InitializeWithContent(url, "", headers, content); # ifdef OUTPUT_DEBUG // Debug code std::cout << "Got content:\n" << content << std::endl; std::wostringstream ss; boost::property_tree::write_json( ss, response.pt ); std::cout << "Got JSON:\n" << mf::utils::wide_to_bytes(ss.str()) << std::endl; # endif if ( ! response.error_code ) { GetIfExists( response.pt, "response.pkey", &response.pkey ); if ( ! GetIfExists( response.pt, "response.login_token", &response.login_token ) ) { response.error_code = make_error_code( mf::api::api_code::ContentInvalidData ); response.error_string = "missing session token"; } } callback_(response); }
void v1_3::Request::HandleContent(const std::string & url, const mf::http::Headers & headers, const std::string & content) { assert(callback_); if (!callback_) return; ResponseType response; response.InitializeWithContent(url, "", headers, content); // These could possibly be available when an error occurs or on success. GetIfExists(response.pt, "response.pkey", &response.pkey); GetIfExists(response.pt, "response.secret_key", &response.secret_key); GetIfExists(response.pt, "response.time", &response.time); if (!response.error_code) { if (!GetIfExists(response.pt, "response.session_token", &response.session_token)) { response.error_code = make_error_code(mf::api::api_code::ContentInvalidData); response.error_string = "missing session token"; } if (!GetIfExists(response.pt, "response.ekey", &response.ekey)) { response.error_code = make_error_code(mf::api::api_code::ContentInvalidData); response.error_string = "missing \"response.ekey\""; } } callback_(response); }