You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
850 B

  1. /*
  2. * weighttp - a lightweight and simple webserver benchmarking tool
  3. *
  4. * Author:
  5. * Copyright (c) 2009 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_200;
  34. int64_t content_length;
  35. uint64_t bytes_received; /* including http header */
  36. uint16_t header_size;
  37. char buffer[CLIENT_BUFFER_SIZE];
  38. };
  39. Client *client_new(Worker *worker);
  40. void client_free(Client *client);
  41. void client_state_machine(Client *client);