issue #2305: Using c++11 std::thread instead of pthread for HttpClient class.

Also fixed a crash when error is triggered in WebSocket. Using std::lock_guard to replace lock and unlock manually.