Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixed client_get_timeout_test using localhost server#533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deanberris merged 1 commit intocpp-netlib:0.11-develfromleecoder:0.11-devel
May 22, 2015
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed client_get_timeout_test
  • Loading branch information
@leecoder
leecoder committedMay 22, 2015
commit4271ca5c49b79cd0aec65be904dd9685f291ac79
30 changes: 20 additions & 10 deletionslibs/network/test/http/client_get_timeout_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,8 +8,23 @@
#include <boost/network/include/http/client.hpp>
#include <boost/test/unit_test.hpp>
#include "client_types.hpp"
#include "http_test_server.hpp"

namespace http = boost::network::http;
struct localhost_server_fixture {
localhost_server_fixture() {
if (!server.start())
std::cout << "Failed to start HTTP server for test!" << std::endl;
}

~localhost_server_fixture() {
if (!server.stop())
std::cout << "Failed to stop HTTP server for test!" << std::endl;
}

http_test_server server;
};

BOOST_GLOBAL_FIXTURE(localhost_server_fixture);

BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_1_0, client, client_types) {
typename client::request request("http://localhost:12121/");
Expand All@@ -22,11 +37,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_1_0, client, client_types) {
, std::exception);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client,
client_types) {
typename client::request request(
"http://cznic.dl.sourceforge.net/project/boost/boost/1.55.0/"
"boost_1_55_0.tar.bz2");
BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client, client_types) {
typename client::request request("http://localhost:8000/cgi-bin/sleep.py?3");
typename client::response response;
typename client::options options;
client client_(options.timeout(1));
Expand All@@ -37,10 +49,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_get_test_timeout_with_options, client,

#ifdef BOOST_NETWORK_ENABLE_HTTPS

BOOST_AUTO_TEST_CASE_TEMPLATE(https_get_test_timeout_with_options, client,
client_types) {
typename client::request request(
"https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.2.tar.bz2");
BOOST_AUTO_TEST_CASE_TEMPLATE(https_get_test_timeout_with_options, client, client_types) {
typename client::request request("https://localhost:8000/cgi-bin/sleep.py?3");
typename client::response response;
typename client::options options;
client client_(options.timeout(1));
Expand Down
19 changes: 13 additions & 6 deletionslibs/network/test/http/http_test_server.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,13 +68,20 @@ struct http_test_server {

// if executed from $CPP_NETLIB_HOME
path server_path = base_path / "libs/network/test/server" / script_name;
if (!exists(server_path)) {
// if executed from $CPP_NETLIB_HOME/libs/network/test
server_path = base_path / "server" / script_name;
if (!exists(server_path)) return path();
}
if (exists(server_path))
return server_path;

// if executed from $CPP_NETLIB_HOME/libs/network/test
server_path = base_path / "server" / script_name;
if (exists(server_path))
return server_path;

// if executed from $CPP_NETLIB_HOME/libs/network/test/*
server_path = base_path / "../server" / script_name;
if (exists(server_path))
return server_path;

returnserver_path;
returnpath();
}

script_handle_t launch_python_script(
Expand Down
8 changes: 8 additions & 0 deletionslibs/network/test/server/cgi-bin/sleep.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
#!/usr/bin/python
importos,sys,time

ifos.environ.has_key("QUERY_STRING")andos.environ["QUERY_STRING"].isdigit():
time.sleep(int(os.environ["QUERY_STRING"]))

sys.stdout.write("HTTP/1.0 200\r\n" )
sys.stdout.write("\r\n" )

[8]ページ先頭

©2009-2025 Movatter.jp