wn_request.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * File : wn_request.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
  5. *
  6. * This software is dual-licensed: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation. For the terms of this
  9. * license, see <http://www.gnu.org/licenses/>.
  10. *
  11. * You are free to use this software under the terms of the GNU General
  12. * Public License, but WITHOUT ANY WARRANTY; without even the implied
  13. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. * See the GNU General Public License for more details.
  15. *
  16. * Alternatively for commercial application, you can contact us
  17. * by email <business@rt-thread.com> for commercial license.
  18. *
  19. * Change Logs:
  20. * Date Author Notes
  21. * 2011-08-02 Bernard the first version
  22. * 2011-08-18 Bernard added content length field
  23. */
  24. #ifndef __WN_REQUEST_H__
  25. #define __WN_REQUEST_H__
  26. #include <rtthread.h>
  27. #include <wn_session.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* http request method */
  32. enum webnet_method
  33. {
  34. WEBNET_UNKNOWN = 0,
  35. WEBNET_GET,
  36. WEBNET_POST,
  37. WEBNET_HEADER,
  38. WEBNET_HEAD,
  39. WEBNET_PUT,
  40. WEBNET_OPTIONS,
  41. WEBNET_PROPFIND,
  42. WEBNET_PROPPATCH,
  43. WEBNET_DELETE,
  44. WEBNET_CONNECT,
  45. WEBNET_MKCOL,
  46. WEBNET_MOVE,
  47. WEBNET_SUBSCRIBE,
  48. WEBNET_UNSUBSCRIBE,
  49. WEBNET_NOTIFY,
  50. };
  51. /* http connection status */
  52. enum webnet_connection
  53. {
  54. WEBNET_CONN_CLOSE,
  55. WEBNET_CONN_KEEPALIVE,
  56. };
  57. /* http request structure */
  58. struct webnet_request
  59. {
  60. enum webnet_method method;
  61. int result_code;
  62. int content_length;
  63. /* the corresponding session */
  64. struct webnet_session *session;
  65. /* path and authorization */
  66. char* path;
  67. char* host;
  68. char* authorization;
  69. #if WEBNET_CACHE_LEVEL > 0
  70. char* modified;
  71. #endif /* WEBNET_CACHE_LEVEL */
  72. #ifdef WEBNET_USING_GZIP
  73. rt_bool_t support_gzip;
  74. #endif /* WEBNET_USING_GZIP */
  75. char* user_agent;
  76. char* accept_language;
  77. char* cookie;
  78. char* referer;
  79. #ifdef WEBNET_USING_RANGE
  80. char *Range;
  81. size_t pos_start;
  82. size_t pos_end;
  83. #endif /* WEBNET_USING_RANGE */
  84. #ifdef WEBNET_USING_DAV
  85. char* depth;
  86. char* destination;
  87. #endif /* WEBNET_USING_DAV */
  88. /* DMR */
  89. char *soap_action;
  90. char *callback;
  91. char *sid;
  92. /* Content-Type */
  93. char* content_type;
  94. /* query information */
  95. char* query;
  96. int query_offset;
  97. struct webnet_query_item* query_items;
  98. rt_uint16_t query_counter;
  99. enum webnet_connection connection;
  100. /* whether the string filed is copied */
  101. rt_bool_t field_copied;
  102. };
  103. struct webnet_request* webnet_request_create(void);
  104. void webnet_request_destory(struct webnet_request* request);
  105. int webnet_request_parse_method(struct webnet_request *request, char* buffer, int length);
  106. int webnet_request_parse_header(struct webnet_request *request, char* buffer, int length);
  107. int webnet_request_parse_post(struct webnet_request* request, char* buffer, int length);
  108. void webnet_request_parse(struct webnet_request* request, char* buffer, int length);
  109. rt_bool_t webnet_request_has_query(struct webnet_request* request, char* name);
  110. const char* webnet_request_get_query(struct webnet_request* request, char* name);
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif /* __WN_REQUEST_H__ */