class TestServer

Defined at line 21 of file ../../src/chromium/web_runner_tests/test_server.h

This is a simple TCP server that binds to a random port on localhost and

serves a single connection.

Public Methods

bool FindAndBindPort ()

This attempts to find an available port the server to.

Defined at line 23 of file ../../src/chromium/web_runner_tests/test_server.cc

int port ()

Port number in use.

Defined at line 44 of file ../../src/chromium/web_runner_tests/test_server.h

template <typename T>
auto ServeAsync (T serve)

Runs a |serve| routine on its own thread, with proper cleanup to prevent

deadlock. |serve| must terminate after |Accept()| returns false.

The return value is a deferred action which, when destroyed, closes

the server (i.e. RAII semantics).

Defined at line 51 of file ../../src/chromium/web_runner_tests/test_server.h

void Close ()

Closes the bound socket file descriptor, cancelling any pending |Accept|.

Defined at line 67 of file ../../src/chromium/web_runner_tests/test_server.cc

bool Accept ()

This accepts exactly one incoming connection.

Defined at line 69 of file ../../src/chromium/web_runner_tests/test_server.cc

bool Read (std::string * buf)

This reads data from the currently open connection into the provided

|buf|. On success, this resizes |buf| to the number of bytes read.

Defined at line 96 of file ../../src/chromium/web_runner_tests/test_server.cc

bool Write (const std::string & buf)

Writes data from |buf| into the currently open connection.

Defined at line 104 of file ../../src/chromium/web_runner_tests/test_server.cc

bool WriteContent (const std::string & content)

Writes message content into the currently open connection, preceeded by an

appropriate HTTP response header.

Defined at line 109 of file ../../src/chromium/web_runner_tests/test_server.cc