]>
Commit | Line | Data |
---|---|---|
b32b8144 | 1 | // |
92f5a8d4 | 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) |
b32b8144 FG |
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 | ||
10 | #ifndef BOOST_BEAST_HTTP_ERROR_HPP | |
11 | #define BOOST_BEAST_HTTP_ERROR_HPP | |
12 | ||
13 | #include <boost/beast/core/detail/config.hpp> | |
14 | #include <boost/beast/core/error.hpp> | |
15 | ||
16 | namespace boost { | |
17 | namespace beast { | |
18 | namespace http { | |
19 | ||
20 | /// Error codes returned from HTTP algorithms and operations. | |
21 | enum class error | |
22 | { | |
23 | /** The end of the stream was reached. | |
24 | ||
11fdf7f2 | 25 | This error is returned when attempting to read HTTP data, |
92f5a8d4 | 26 | and the stream returns the error `net::error::eof` |
11fdf7f2 TL |
27 | before any octets corresponding to a new HTTP message have |
28 | been received. | |
b32b8144 FG |
29 | */ |
30 | end_of_stream = 1, | |
31 | ||
32 | /** The incoming message is incomplete. | |
33 | ||
34 | This happens when the end of stream is reached during | |
35 | parsing and some octets have been received, but not the | |
36 | entire message. | |
37 | */ | |
38 | partial_message, | |
39 | ||
40 | /** Additional buffers are required. | |
41 | ||
42 | This error is returned during parsing when additional | |
43 | octets are needed. The caller should append more data | |
44 | to the existing buffer and retry the parse operaetion. | |
45 | */ | |
46 | need_more, | |
47 | ||
48 | /** An unexpected body was encountered during parsing. | |
49 | ||
50 | This error is returned when attempting to parse body | |
51 | octets into a message container which has the | |
52 | @ref empty_body body type. | |
53 | ||
92f5a8d4 | 54 | @see empty_body |
b32b8144 FG |
55 | */ |
56 | unexpected_body, | |
57 | ||
58 | /** Additional buffers are required. | |
59 | ||
60 | This error is returned under the following conditions: | |
61 | ||
62 | @li During serialization when using @ref buffer_body. | |
63 | The caller should update the body to point to a new | |
64 | buffer or indicate that there are no more octets in | |
65 | the body. | |
66 | ||
67 | @li During parsing when using @ref buffer_body. | |
68 | The caller should update the body to point to a new | |
69 | storage area to receive additional body octets. | |
70 | */ | |
71 | need_buffer, | |
72 | ||
73 | /** The end of a chunk was reached | |
74 | */ | |
75 | end_of_chunk, | |
76 | ||
77 | /** Buffer maximum exceeded. | |
78 | ||
79 | This error is returned when reading HTTP content | |
80 | into a dynamic buffer, and the operation would | |
81 | exceed the maximum size of the buffer. | |
82 | */ | |
83 | buffer_overflow, | |
84 | ||
85 | /** Header limit exceeded. | |
86 | ||
87 | The parser detected an incoming message header which | |
88 | exceeded a configured limit. | |
89 | */ | |
90 | header_limit, | |
91 | ||
92 | /** Body limit exceeded. | |
93 | ||
94 | The parser detected an incoming message body which | |
95 | exceeded a configured limit. | |
96 | */ | |
97 | body_limit, | |
98 | ||
99 | /** A memory allocation failed. | |
100 | ||
101 | When basic_fields throws std::bad_alloc, it is | |
102 | converted into this error by @ref parser. | |
103 | */ | |
104 | bad_alloc, | |
105 | ||
106 | // | |
107 | // (parser errors) | |
108 | // | |
109 | ||
110 | /// The line ending was malformed | |
111 | bad_line_ending, | |
112 | ||
113 | /// The method is invalid. | |
114 | bad_method, | |
115 | ||
116 | /// The request-target is invalid. | |
117 | bad_target, | |
118 | ||
119 | /// The HTTP-version is invalid. | |
120 | bad_version, | |
121 | ||
122 | /// The status-code is invalid. | |
123 | bad_status, | |
124 | ||
125 | /// The reason-phrase is invalid. | |
126 | bad_reason, | |
127 | ||
128 | /// The field name is invalid. | |
129 | bad_field, | |
130 | ||
131 | /// The field value is invalid. | |
132 | bad_value, | |
133 | ||
134 | /// The Content-Length is invalid. | |
135 | bad_content_length, | |
136 | ||
137 | /// The Transfer-Encoding is invalid. | |
138 | bad_transfer_encoding, | |
139 | ||
140 | /// The chunk syntax is invalid. | |
141 | bad_chunk, | |
142 | ||
143 | /// The chunk extension is invalid. | |
144 | bad_chunk_extension, | |
145 | ||
146 | /// An obs-fold exceeded an internal limit. | |
92f5a8d4 TL |
147 | bad_obs_fold, |
148 | ||
149 | /** The parser is stale. | |
150 | ||
151 | This happens when attempting to re-use a parser that has | |
152 | already completed parsing a message. Programs must construct | |
153 | a new parser for each message. This can be easily done by | |
154 | storing the parser in an boost or std::optional container. | |
155 | */ | |
f67539c2 TL |
156 | stale_parser, |
157 | ||
158 | /** The message body is shorter than expected. | |
159 | ||
160 | This error is returned by @ref file_body when an unexpected | |
161 | unexpected end-of-file condition is encountered while trying | |
162 | to read from the file. | |
163 | */ | |
164 | short_read | |
b32b8144 FG |
165 | }; |
166 | ||
167 | } // http | |
168 | } // beast | |
169 | } // boost | |
170 | ||
92f5a8d4 TL |
171 | #include <boost/beast/http/impl/error.hpp> |
172 | #ifdef BOOST_BEAST_HEADER_ONLY | |
b32b8144 | 173 | #include <boost/beast/http/impl/error.ipp> |
92f5a8d4 | 174 | #endif |
b32b8144 FG |
175 | |
176 | #endif |