private-lib-roles-cgi.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * libwebsockets - small server side websockets and web server implementation
  3. *
  4. * Copyright (C) 2010 - 2019 Andy Green <[email protected]>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to
  8. * deal in the Software without restriction, including without limitation the
  9. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10. * sell copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  22. * IN THE SOFTWARE.
  23. *
  24. * This is included from private-lib-core.h if LWS_ROLE_WS
  25. */
  26. #if defined(LWS_WITH_ZLIB)
  27. #if defined(LWS_WITH_MINIZ)
  28. #include <miniz.h>
  29. #else
  30. #include <zlib.h>
  31. #endif
  32. #endif
  33. extern const struct lws_role_ops role_ops_cgi;
  34. #define lwsi_role_cgi(wsi) (wsi->role_ops == &role_ops_cgi)
  35. #define LWS_HTTP_CHUNK_HDR_SIZE 16
  36. enum {
  37. SIGNIFICANT_HDR_CONTENT_LENGTH, /* numeric */
  38. SIGNIFICANT_HDR_LOCATION,
  39. SIGNIFICANT_HDR_STATUS, /* numeric */
  40. SIGNIFICANT_HDR_TRANSFER_ENCODING,
  41. SIGNIFICANT_HDR_CONTENT_ENCODING_GZIP,
  42. SIGNIFICANT_HDR_COUNT
  43. };
  44. struct lws;
  45. /* wsi who is master of the cgi points to an lws_cgi */
  46. struct lws_cgi {
  47. struct lws_cgi *cgi_list;
  48. struct lws_spawn_piped *lsp;
  49. lws_sorted_usec_list_t sul_grace;
  50. struct lws *wsi; /* owner */
  51. unsigned char *headers_buf;
  52. unsigned char *headers_start;
  53. unsigned char *headers_pos;
  54. unsigned char *headers_dumped;
  55. unsigned char *headers_end;
  56. char summary[128];
  57. #if defined(LWS_WITH_ZLIB)
  58. z_stream inflate;
  59. uint8_t inflate_buf[1024];
  60. #endif
  61. lws_filepos_t post_in_expected;
  62. lws_filepos_t content_length;
  63. lws_filepos_t content_length_seen;
  64. int match[SIGNIFICANT_HDR_COUNT];
  65. char l[12];
  66. int response_code;
  67. int lp;
  68. unsigned char being_closed:1;
  69. unsigned char explicitly_chunked:1;
  70. unsigned char cgi_transaction_over:1;
  71. unsigned char implied_chunked:1;
  72. unsigned char gzip_inflate:1;
  73. unsigned char gzip_init:1;
  74. unsigned char chunked_grace;
  75. };