HTTPTypes.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #pragma once
  2. using namespace std;
  3. namespace HTTP
  4. {
  5. /******************************************************************************
  6. 错误代码定义
  7. ******************************************************************************/
  8. typedef enum ErrorCode
  9. {
  10. CUT_URL_PTL_URL_NULL = 1, //URL为空
  11. CUT_URL_PTL_PTL_TAIL_POS, //找不到协议尾部符号位置
  12. CUT_URL_PTL_PTL_NULL, //提取协议失败
  13. CUT_URL_PTL_PTL_UNKNOW, //未知的协议
  14. CUT_URL_DOMAIN_PTL_TAIL_POS, //找不到协议尾部符号位置
  15. CUT_URL_DOMAIN_URL_NULL, //URL为空
  16. CUT_URL_DOMAIN_DOMAIN_HEAD_POS, //域名头部位置无效
  17. CUT_URL_DOMAIN_DOMAIN_TAIL_POS, //找不到域名尾部符号位置
  18. CUT_URL_DOMAIN_DOMAIN_NULL, //提取域名失败
  19. PROCESS_DOMAIN_PORT_DOMAIN_NULL, //域名为空
  20. PROCESS_DOMAIN_PORT_PORT_POS, //端口定位失败
  21. PROCESS_DOMAIN_PORT_PORT_NULL, //提取端口失败
  22. PROCESS_DOMAIN_PORT_PORT_ZERO, //端口号为0
  23. PROCESS_DOMAIN_PORT_DOMAIN_RECUT, //重新提取域名失败
  24. CUT_URL_PATH_URL_NULL, //URL为空
  25. CUT_URL_PATH_DOMAIN_TAIL_POS, //域名尾部符号位置无效
  26. CUT_URL_PATH_PATH_NULL, //提取路径失败
  27. ENCODE_POST_DATA_FAIL, //对POST进行编码转换失败
  28. TRANS_CODE_PAGE_WC_FAIL, //转换成宽字符编码失败
  29. TRANS_CODE_PAGE_WC_NULL, //转换成宽字符编码为空
  30. TRANS_CODE_PAGE_DST_FAIL, //转换成目标编码失败
  31. TRANS_CODE_PAGE_DST_NULL, //转换成目标编码为空
  32. TRANS_DATA_TO_STR_SIZE_INVALID, //数据大小有误
  33. TRANS_DATA_TO_STR_DATA_NULL, //数据为空
  34. TRANS_DATA_TO_STR_REBUF_FAIL, //更改内存大小失败
  35. TRANS_DATA_TO_STR_STR_NULL, //转换为字符串为空
  36. ENCODE_RECV_STR_FAIL, //转换编码失败
  37. PARSE_COOKIE_STR_COOKIE_NULL, //Cookie为空串
  38. PARSE_COOKIE_STR_NAME_NULL, //Cookie名为空
  39. ADD_COOKIE_STRING_COOKIE_NULL, //添加Cookie为空
  40. ADD_COOKIE_STRING_NAME_NULL, //添加Cookie名为空
  41. ADD_COOKIE_SCOOKIE_NAME_NULL, //Cookie名为空
  42. ADD_COOKIE_SOCKET_FIND_INVALID, //找到的下标有误
  43. GET_IMG_DATA_NULL, //接收的数据为空
  44. GET_IMG_SIZE_INVALID, //接收的数据大小无效
  45. GET_IP_STR_DOMAIN_NULL, //域名为空
  46. GET_IP_STR_IP_NULL, //获取的IP地址为空
  47. GET_IP_STR_IPW_FAIL, //转换为宽字符串失败
  48. GET_IP_STR_IPW_NULL, //转换为宽字符串为空
  49. STARTUP_CREATE_SOCKET_STARTUP, //启动套接字失败
  50. STARTUP_CREATE_SOCKET_SOCKET, //创建套接字失败
  51. FILL_ADDR_INFO_DOMAIN_NULL, //域名为空
  52. FILL_ADDR_INFO_IP_ZERO, //IP数据无效
  53. FILL_ADDR_INFO_PORT_INVALID, //端口无效
  54. SELECT_TIMEOUT_TIMEOUT_INVALID, //超时值无效
  55. SELECT_TIMEOUT_INVALID_SOCKET, //套接字无效
  56. SELECT_TIMEOUT_CONN_TIMEOUT, //连接超时
  57. CONN_WITH_TIMEOUT_INVALID_SOCKET, //套接字无效
  58. CONN_WITH_TIMEOUT_SETNB_FAIL, //设置非阻塞模式失败
  59. CONN_WITH_TIMEOUT_ADDR_INVALID, //地址信息无效
  60. CONN_WITH_TIMEOUT_CONN_FAIL, //连接失败
  61. CONN_WITH_TIMEOUT_SETB_FAIL, //设置阻塞模式失败
  62. SET_SOCKET_TIMEOUT_INVALID_SOCKET, //套接字无效
  63. SET_SOCKET_TIMEOUT_VALUE_INVALID, //超时值无效
  64. SET_SOCKET_TIMEOUT_SET_SND_TIMEOUT, //设置发送超时失败
  65. SET_SOCKET_TIMEOUT_SET_RCV_TIMEOUT, //设置接收超时失败
  66. SEND_DATA_PATH_NULL, //路径为空
  67. SEND_DATA_INVALID_SOCKET, //套接字无效
  68. SEND_DATA_SEND_FAIL, //发送失败
  69. RECV_EACH_DATA_SIZE_INVALID, //接收数据大小无效
  70. RECV_EACH_DATA_MALLOC_FAIL, //申请内存失败
  71. RECV_EACH_DATA_INVALID_SOCKET, //套接字无效
  72. RECV_EACH_DATA_CONN_CLOSE, //连接断开
  73. RECV_EACH_DATA_RECV_FAIL, //接收失败
  74. GET_RESPONSE_COOKIES_RECV_DATA_NULL, //接收到的数据为空
  75. GET_RESPONSE_COOKIES_HEADER_LEN_INVALID, //响应头长度无效
  76. GET_RESPONSE_COOKIES_HEADER_NULL, //响应头为空
  77. REJECT_HEADER_DATA_SIZE_INVALID, //接收数据大小无效
  78. REJECT_HEADER_HEADER_LEN_INVALID, //响应头长度无效
  79. REJECT_HEADER_RECV_DATA_NULL, //接收到的数据为空
  80. END_VISIT_CLOSE_FAIL, //关闭套接字失败
  81. END_VISIT_CLEAN_FAIL, //清空套接字失败
  82. }EErrorCode;
  83. typedef enum Timeout
  84. {
  85. CONN_TIMEOUT_DEFAULT = 10 * 1000, //默认的连接超时
  86. SEND_TIMEOUT_DEFAULT = 10 * 1000, //默认的发送超时
  87. RECV_TIMEOUT_DEFAULT = 10 * 1000, //默认的接收超时
  88. }ETimeout;
  89. typedef struct Cookie
  90. {
  91. string strName; //Cookie名
  92. string strValue; //Cookie值
  93. string strPath; //Cookie路径
  94. string strDomain; //Cookie域名
  95. }SCookie;
  96. typedef enum Const
  97. {
  98. RECV_BUF_SIZE = 1024, //每次接收的数据大小
  99. }EConst;
  100. }