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