src/client.h - weighttp

Data types defined

Source code

  1. /*
  2. * weighttp - a lightweight and simple webserver benchmarking tool
  3. *
  4. * Author:
  5. *     Copyright (c) 2009-2011 Thomas Porzelt
  6. *
  7. * License:
  8. *     MIT, see COPYING file
  9. */

  10. struct Client {
  11.     enum {
  12.         CLIENT_START,
  13.         CLIENT_CONNECTING,
  14.         CLIENT_WRITING,
  15.         CLIENT_READING,
  16.         CLIENT_ERROR,
  17.         CLIENT_END
  18.     } state;

  19.     enum {
  20.         PARSER_START,
  21.         PARSER_HEADER,
  22.         PARSER_BODY
  23.     } parser_state;

  24.     Worker *worker;
  25.     ev_io sock_watcher;
  26.     uint32_t buffer_offset;
  27.     uint32_t parser_offset;
  28.     uint32_t request_offset;
  29.     ev_tstamp ts_start;
  30.     ev_tstamp ts_end;
  31.     uint8_t keepalive;
  32.     uint8_t success;
  33.     uint8_t status_success;
  34.     uint8_t chunked;
  35.     int64_t chunk_size;
  36.     int64_t chunk_received;
  37.     int64_t content_length;
  38.     uint64_t bytes_received; /* including http header */
  39.     uint16_t header_size;

  40.     char buffer[CLIENT_BUFFER_SIZE];
  41. };

  42. Client *client_new(Worker *worker);
  43. void client_free(Client *client);
  44. void client_state_machine(Client *client);