error.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_HTTP_ERROR_HPP
  10. #define BOOST_BEAST_HTTP_ERROR_HPP
  11. #include <boost/beast/core/detail/config.hpp>
  12. #include <boost/beast/core/error.hpp>
  13. namespace boost {
  14. namespace beast {
  15. namespace http {
  16. /// Error codes returned from HTTP algorithms and operations.
  17. enum class error
  18. {
  19. /** The end of the stream was reached.
  20. This error is returned when attempting to read HTTP data,
  21. and the stream returns the error `net::error::eof`
  22. before any octets corresponding to a new HTTP message have
  23. been received.
  24. */
  25. end_of_stream = 1,
  26. /** The incoming message is incomplete.
  27. This happens when the end of stream is reached during
  28. parsing and some octets have been received, but not the
  29. entire message.
  30. */
  31. partial_message,
  32. /** Additional buffers are required.
  33. This error is returned during parsing when additional
  34. octets are needed. The caller should append more data
  35. to the existing buffer and retry the parse operaetion.
  36. */
  37. need_more,
  38. /** An unexpected body was encountered during parsing.
  39. This error is returned when attempting to parse body
  40. octets into a message container which has the
  41. @ref empty_body body type.
  42. @see empty_body
  43. */
  44. unexpected_body,
  45. /** Additional buffers are required.
  46. This error is returned under the following conditions:
  47. @li During serialization when using @ref buffer_body.
  48. The caller should update the body to point to a new
  49. buffer or indicate that there are no more octets in
  50. the body.
  51. @li During parsing when using @ref buffer_body.
  52. The caller should update the body to point to a new
  53. storage area to receive additional body octets.
  54. */
  55. need_buffer,
  56. /** The end of a chunk was reached
  57. */
  58. end_of_chunk,
  59. /** Buffer maximum exceeded.
  60. This error is returned when reading HTTP content
  61. into a dynamic buffer, and the operation would
  62. exceed the maximum size of the buffer.
  63. */
  64. buffer_overflow,
  65. /** Header limit exceeded.
  66. The parser detected an incoming message header which
  67. exceeded a configured limit.
  68. */
  69. header_limit,
  70. /** Body limit exceeded.
  71. The parser detected an incoming message body which
  72. exceeded a configured limit.
  73. */
  74. body_limit,
  75. /** A memory allocation failed.
  76. When basic_fields throws std::bad_alloc, it is
  77. converted into this error by @ref parser.
  78. */
  79. bad_alloc,
  80. //
  81. // (parser errors)
  82. //
  83. /// The line ending was malformed
  84. bad_line_ending,
  85. /// The method is invalid.
  86. bad_method,
  87. /// The request-target is invalid.
  88. bad_target,
  89. /// The HTTP-version is invalid.
  90. bad_version,
  91. /// The status-code is invalid.
  92. bad_status,
  93. /// The reason-phrase is invalid.
  94. bad_reason,
  95. /// The field name is invalid.
  96. bad_field,
  97. /// The field value is invalid.
  98. bad_value,
  99. /// The Content-Length is invalid.
  100. bad_content_length,
  101. /// The Transfer-Encoding is invalid.
  102. bad_transfer_encoding,
  103. /// The chunk syntax is invalid.
  104. bad_chunk,
  105. /// The chunk extension is invalid.
  106. bad_chunk_extension,
  107. /// An obs-fold exceeded an internal limit.
  108. bad_obs_fold,
  109. /** The parser is stale.
  110. This happens when attempting to re-use a parser that has
  111. already completed parsing a message. Programs must construct
  112. a new parser for each message. This can be easily done by
  113. storing the parser in an boost or std::optional container.
  114. */
  115. stale_parser
  116. };
  117. } // http
  118. } // beast
  119. } // boost
  120. #include <boost/beast/http/impl/error.hpp>
  121. #ifdef BOOST_BEAST_HEADER_ONLY
  122. #include <boost/beast/http/impl/error.ipp>
  123. #endif
  124. #endif