+Client::Client(int sock)
+ : sock(sock),
+ state(Client::READING_REQUEST),
+ header_bytes_sent(0),
+ bytes_sent(0)
+{
+ request.reserve(1024);
+}
+
+Client::Client(const ClientProto &serialized)
+ : sock(serialized.sock()),
+ state(State(serialized.state())),
+ request(serialized.request()),
+ stream_id(serialized.stream_id()),
+ header(serialized.header()),
+ header_bytes_sent(serialized.header_bytes_sent()),
+ bytes_sent(serialized.bytes_sent())
+{
+}
+
+ClientProto Client::serialize() const
+{
+ ClientProto serialized;
+ serialized.set_sock(sock);
+ serialized.set_state(state);
+ serialized.set_request(request);
+ serialized.set_stream_id(stream_id);
+ serialized.set_header(header);
+ serialized.set_header_bytes_sent(serialized.header_bytes_sent());
+ serialized.set_bytes_sent(bytes_sent);
+ return serialized;
+}
+