/* Chooses the appropriate connection, or opens a new one if necessary. Wraps xml in HTTP and sends. */ bool ConnBoshMultStat::sendRequest( const std::string& xml ) { ConnectionBase* conn = getConnection(); if( !conn ) return false; std::string request = "POST " + m_path; if( m_connMode == ModeLegacyHTTP ) { request += " HTTP/1.0\r\n"; request += "Connection: close\r\n"; } else request += " HTTP/1.1\r\n"; request += "Host: " + m_boshedHost + "\r\n"; request += "Content-Type: text/xml; charset=utf-8\r\n"; request += "Content-Length: " + util::int2string( xml.length() ) + "\r\n"; request += "User-Agent: gloox/" + GLOOX_VERSION + "\r\n\r\n"; request += xml; if( conn->send( request ) ) { m_lastRequestTime = time( 0 ); ++m_openRequests; return true; } // else // FIXME What to do in this case? // printf( "Error while trying to send on socket (state: %d)\n", conn->state() ); return false; }