/// @todo We're getting a hostname but in fact it is expected to be an IP address.
/// We should extend the TCPEndpoint to also accept names. Currently, it will fall
/// over for names.
- TCPEndpoint endpoint(url_.getHostname(), static_cast<unsigned short>(url_.getPort()));
+ TCPEndpoint endpoint(url_.getStrippedHostname(),
+ static_cast<unsigned short>(url_.getPort()));
SocketCallback socket_cb(boost::bind(&Connection::connectCallback, shared_from_this(),
request_timeout, _1));
/// @brief IP address to which HTTP service is bound.
const std::string SERVER_ADDRESS = "127.0.0.1";
+/// @brief IPv6 address to whch HTTP service is bound.
+const std::string IPV6_SERVER_ADDRESS = "::1";
+
/// @brief Port number to which HTTP service is bound.
const unsigned short SERVER_PORT = 18123;
io_service_.poll();
}
+
// This test verifies that persistent HTTP connection can be established when
// "Conection: Keep-Alive" header value is specified.
TEST_F(HttpListenerTest, keepAlive) {
listener_(io_service_, IOAddress(SERVER_ADDRESS), SERVER_PORT,
factory_, HttpListener::RequestTimeout(REQUEST_TIMEOUT),
HttpListener::IdleTimeout(IDLE_TIMEOUT)),
- listener2_(io_service_, IOAddress(SERVER_ADDRESS), SERVER_PORT + 1,
+ listener2_(io_service_, IOAddress(IPV6_SERVER_ADDRESS), SERVER_PORT + 1,
factory_, HttpListener::RequestTimeout(REQUEST_TIMEOUT),
HttpListener::IdleTimeout(IDLE_TIMEOUT)),
listener3_(io_service_, IOAddress(SERVER_ADDRESS), SERVER_PORT + 2,
// Specify the URLs on which the servers are available.
Url url1("http://127.0.0.1:18123");
- Url url2("http://127.0.0.1:18124");
+ Url url2("http://[::1]:18124");
// Create a request to the first server.
PostHttpRequestJsonPtr request1 = createRequest("sequence", 1);
// content type.
PostHttpRequestJsonPtr request = createRequest("requested-content-type", "text/html");
HttpResponseJsonPtr response(new HttpResponseJson());
- unsigned resp_num = 0;
ASSERT_NO_THROW(client.asyncSendRequest(url, request, response,
- [this, &resp_num](const boost::system::error_code& ec,
- const HttpResponsePtr& response,
- const std::string& parsing_error) {
+ [this](const boost::system::error_code& ec,
+ const HttpResponsePtr& response,
+ const std::string& parsing_error) {
io_service_.stop();
// There should be no IO error (answer from the server is received).
EXPECT_FALSE(ec);