Body.qbk 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. [/
  2. Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. Official repository: https://github.com/boostorg/beast
  6. ]
  7. [section:Body Body]
  8. A [*Body] type is supplied as a template argument to the __message__ class. It
  9. controls both the type of the data member of the resulting message object, and
  10. the algorithms used during parsing and serialization.
  11. [heading Associated Types]
  12. * [link beast.ref.boost__beast__http__is_body `is_body`]
  13. * __BodyReader__
  14. * __BodyWriter__
  15. [heading Requirements]
  16. In this table:
  17. * `B` is a type meeting the requirements of [*Body].
  18. * `m` is a value of type `message<b,B,F>` where `b` is a `bool` value
  19. and `F` is a type meeting the requirements of __Fields__.
  20. [table Valid expressions
  21. [[Expression] [Type] [Semantics, Pre/Post-conditions]]
  22. [
  23. [`B::value_type`]
  24. []
  25. [
  26. The return type of the `message::body` member function.
  27. If this is not movable or not copyable, the containing message
  28. will be not movable or not copyable.
  29. ]
  30. ][
  31. [`B::reader`]
  32. []
  33. [
  34. If present, indicates that the body can be parsed. The type
  35. must meet the requirements of __BodyReader__. The implementation
  36. constructs an object of this type to obtain buffers into which
  37. parsed body octets are placed.
  38. ]
  39. ][
  40. [`B::writer`]
  41. []
  42. [
  43. If present, indicates that the body is serializable. The type
  44. must meet the requirements of __BodyWriter__. The implementation
  45. constructs an object of this type to obtain buffers representing
  46. the message body for serialization.
  47. ]
  48. ][
  49. [
  50. ```
  51. B::size(
  52. B::value_type body)
  53. ```
  54. ]
  55. [`std::uint64_t`]
  56. [
  57. This static member function is optional. It returns the payload
  58. size of `body` in bytes not including any chunked transfer encoding.
  59. The return value may be zero, to indicate that the message is known
  60. to have no payload. The function shall not exit via an exception.
  61. When this function is present:
  62. * The function shall not fail
  63. * A call to
  64. [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`]
  65. will return the same value as `size`.
  66. * A call to
  67. [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`]
  68. will remove "chunked" from the Transfer-Encoding field if it appears
  69. as the last encoding, and will set the Content-Length field to the
  70. returned value.
  71. Otherwise, when the function is omitted:
  72. * A call to
  73. [link beast.ref.boost__beast__http__message.payload_size `message::payload_size`]
  74. will return `boost::none`.
  75. * A call to
  76. [link beast.ref.boost__beast__http__message.prepare_payload `message::prepare_payload`]
  77. will erase the Content-Length field, and add "chunked" as the last
  78. encoding in the Transfer-Encoding field if it is not already present.
  79. ]
  80. ]]
  81. [heading Exemplar]
  82. [concept_Body]
  83. [heading Models]
  84. * [link beast.ref.boost__beast__http__basic_dynamic_body `basic_dynamic_body`]
  85. * [link beast.ref.boost__beast__http__basic_file_body `basic_file_body`]
  86. * [link beast.ref.boost__beast__http__basic_string_body `basic_string_body`]
  87. * [link beast.ref.boost__beast__http__buffer_body `buffer_body`]
  88. * [link beast.ref.boost__beast__http__empty_body `empty_body`]
  89. * [link beast.ref.boost__beast__http__span_body `span_body`]
  90. * [link beast.ref.boost__beast__http__vector_body `vector_body`]
  91. [endsect]