Write the request body to the IO stream before piping the request socket in.
Move most WebSocket logic into the API class so that the server and client classes just deal with getting a parser and setting up an IO stream.
Implement the read/write stream interface on the API class.