| 205 | // ---------------------------------------------------------------------------------------- |
| 206 | |
| 207 | std::string http_client::get_random_string( size_t length ) const |
| 208 | { |
| 209 | static bool has_seeded(false); |
| 210 | static std::string allowed_chars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); |
| 211 | |
| 212 | if ( !has_seeded ) |
| 213 | { |
| 214 | has_seeded = true; |
| 215 | ::srand( static_cast<unsigned int>(::time(NULL)) ); |
| 216 | } |
| 217 | |
| 218 | std::string retVal; retVal.reserve(length); |
| 219 | while ( retVal.size() < length ) |
| 220 | { |
| 221 | retVal += allowed_chars[(rand() % allowed_chars.size())]; |
| 222 | } |
| 223 | |
| 224 | return retVal; |
| 225 | } |
| 226 | |
| 227 | // ---------------------------------------------------------------------------------------- |
| 228 | |