fixes
This commit is contained in:
parent
64739c39d8
commit
9bdf133d0f
12 changed files with 301 additions and 168 deletions
|
|
@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
import Crafter.Thread;
|
||||
import Crafter.Network;
|
||||
import std;
|
||||
using namespace Crafter;
|
||||
|
|
@ -26,27 +25,19 @@ using namespace Crafter;
|
|||
extern "C" {
|
||||
std::string* RunTest() {
|
||||
bool success = false;
|
||||
ThreadPool::Start(2);
|
||||
ListenerHTTP listener(8080, {{"/", [&](const HTTPRequest& request) {
|
||||
ListenerAsyncHTTP listener(8080, {{"/", [&](const HTTPRequest& request) {
|
||||
success = true;
|
||||
return CreateResponseHTTP("200 OK", "Hello World!");
|
||||
}}});
|
||||
try {
|
||||
listener.ListenAsyncSync();
|
||||
system("curl http://localhost:8080 > /dev/null 2>&1");
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
if (success) {
|
||||
listener.Stop();
|
||||
ThreadPool::Stop();
|
||||
return nullptr;
|
||||
} else {
|
||||
listener.Stop();
|
||||
ThreadPool::Stop();
|
||||
return new std::string("Did not receive");
|
||||
}
|
||||
} catch(std::exception& e) {
|
||||
listener.Stop();
|
||||
ThreadPool::Stop();
|
||||
return new std::string(e.what());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue