dc49af3c59
For now there are two methods: - `NETWORK:IsUrlAllowed()`: Check whether access to a certain URL is allowed. - `NETWORK:HttpRequest()`: Perform an HTTP request. By default access to the network is disabled for all target hosts. It can be enabled by setting `HttpEnable=1` in the preferences. Individual hosts have to be added to `HttpAllowHosts` as a comma separated list to allow access. See included docs for more details on usage.
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
/*
|
|
* IXHttpTest.cpp
|
|
* Author: Benjamin Sergeant
|
|
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
|
*/
|
|
|
|
#include "catch.hpp"
|
|
#include <iostream>
|
|
#include <ixwebsocket/IXHttp.h>
|
|
#include <string.h>
|
|
|
|
namespace ix
|
|
{
|
|
TEST_CASE("http", "[http]")
|
|
{
|
|
SECTION("Normal case")
|
|
{
|
|
std::string line = "HTTP/1.1 200";
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
REQUIRE(result.first == "HTTP/1.1");
|
|
REQUIRE(result.second == 200);
|
|
}
|
|
|
|
SECTION("http/1.0 case")
|
|
{
|
|
std::string line = "HTTP/1.0 200";
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
REQUIRE(result.first == "HTTP/1.0");
|
|
REQUIRE(result.second == 200);
|
|
}
|
|
|
|
SECTION("empty case")
|
|
{
|
|
std::string line = "";
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
REQUIRE(result.first == "");
|
|
REQUIRE(result.second == -1);
|
|
}
|
|
|
|
SECTION("empty case")
|
|
{
|
|
std::string line = "HTTP/1.1";
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
REQUIRE(result.first == "HTTP/1.1");
|
|
REQUIRE(result.second == -1);
|
|
}
|
|
}
|
|
|
|
} // namespace ix
|