• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
10[section:Body Body]
11
12A [*Body] type is supplied as a template argument to the __message__ class. It
13controls both the type of the data member of the resulting message object, and
14the algorithms used during parsing and serialization.
15
16[heading Associated Types]
17
18* [link beast.ref.boost__beast__http__is_body `is_body`]
19* __BodyReader__
20* __BodyWriter__
21
22[heading Requirements]
23
24In this table:
25
26* `B` is a type meeting the requirements of [*Body].
27* `m` is a value of type `message<b,B,F>` where `b` is a `bool` value
28  and `F` is a type meeting the requirements of __Fields__.
29
30[table Valid expressions
31[[Expression] [Type] [Semantics, Pre/Post-conditions]]
32[
33    [`B::value_type`]
34    []
35    [
36        The return type of the `message::body` member function.
37        If this is not movable or not copyable, the containing message
38        will be not movable or not copyable.
39    ]
40][
41    [`B::reader`]
42    []
43    [
44        If present, indicates that the body can be parsed. The type
45        must meet the requirements of __BodyReader__. The implementation
46        constructs an object of this type to obtain buffers into which
47        parsed body octets are placed.
48    ]
49][
50    [`B::writer`]
51    []
52    [
53        If present, indicates that the body is serializable. The type
54        must meet the requirements of __BodyWriter__. The implementation
55        constructs an object of this type to obtain buffers representing
56        the message body for serialization.
57    ]
58][
59    [
60    ```
61    B::size(
62      B::value_type body)
63    ```
64    ]
65    [`std::uint64_t`]
66    [
67        This static member function is optional. It returns the payload
68        size of `body` in bytes not including any chunked transfer encoding.
69        The return value may be zero, to indicate that the message is known
70        to have no payload. The function shall not exit via an exception.
71
72        When this function is present:
73
74        * The function shall not fail
75
76        * A call to
77        [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`]
78        will return the same value as `size`.
79
80        * A call to
81        [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`]
82        will remove "chunked" from the Transfer-Encoding field if it appears
83        as the last encoding, and will set the Content-Length field to the
84        returned value.
85
86        Otherwise, when the function is omitted:
87
88        * A call to
89        [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`]
90        will return `boost::none`.
91
92        * A call to
93        [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`]
94        will erase the Content-Length field, and add "chunked" as the last
95        encoding in the Transfer-Encoding field if it is not already present.
96    ]
97]]
98
99[heading Exemplar]
100
101[concept_Body]
102
103[heading Models]
104
105* [link beast.ref.boost__beast__http__basic_dynamic_body `basic_dynamic_body`]
106* [link beast.ref.boost__beast__http__basic_file_body `basic_file_body`]
107* [link beast.ref.boost__beast__http__basic_string_body `basic_string_body`]
108* [link beast.ref.boost__beast__http__buffer_body `buffer_body`]
109* [link beast.ref.boost__beast__http__empty_body `empty_body`]
110* [link beast.ref.boost__beast__http__span_body `span_body`]
111* [link beast.ref.boost__beast__http__vector_body `vector_body`]
112
113[endsect]
114