4 // A Client represents a single connection from a client (watching a single stream).
15 // Digested statistics for writing to logs etc.
16 // Note that "referer" and "user_agent" here are already escaped for scary characters.
20 std::string remote_addr;
22 std::string user_agent;
23 timespec connect_time;
26 size_t num_loss_events;
32 // Serialization/deserialization.
33 Client(const ClientProto &serialized, Stream *stream);
34 ClientProto serialize() const;
36 ClientStats get_stats() const;
38 // The file descriptor associated with this socket.
41 // When the client connected, in terms of CLOCK_MONOTONIC_COARSE.
42 timespec connect_time;
44 // Some information only used for logging.
45 std::string remote_addr;
47 std::string user_agent;
49 enum State { READING_REQUEST, SENDING_HEADER, SENDING_DATA, SENDING_SHORT_RESPONSE, WAITING_FOR_KEYFRAME, PREBUFFERING };
52 // The HTTP request, as sent by the client. If we are in READING_REQUEST,
53 // this might not be finished.
56 // What stream we're connecting to; parsed from <request>.
57 // Not relevant for READING_REQUEST.
61 // The header we want to send, or the response with headers if we know
62 // it in its entirety after reading the request (typically an error).
63 // This is nominally a copy of Stream::header, but since that might
64 // change on reconnects etc., we keep a local copy here. Only relevant
65 // for SENDING_HEADER or SENDING_SHORT_RESPONSE; blank otherwise.
66 std::string header_or_short_response;
68 // Number of bytes we've sent of the header. Only relevant for SENDING_HEADER
69 // or SENDING_SHORT_RESPONSE.
70 size_t header_or_short_response_bytes_sent;
72 // Number of bytes we are into the stream (ie., the end of last send).
73 // -1 means we want to send from the end of the backlog (the normal case),
74 // although only at a keyframe.
75 // -2 means we want to send from the _beginning_ of the backlog.
76 // Once we go into WAITING_FOR_KEYFRAME, PREBUFFERING or SENDING_DATA,
77 // these negative values will be translated to real numbers.
80 // Number of bytes we've sent of data. Only relevant for SENDING_DATA.
83 // Number of times we've skipped forward due to the backlog being too big,
84 // and how many bytes we've skipped over in all. Only relevant for SENDING_DATA.
85 size_t bytes_lost, num_loss_events;
87 TLSContext *tls_context;
88 const unsigned char *tls_data_to_send;
89 unsigned tls_data_left_to_send;
93 #endif // !defined(_CLIENT_H)