Fields.qbk 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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:Fields Fields]
  8. [warning
  9. The ['Fields] concept is deprecated and will be removed in
  10. a future version. The information on this page is provided
  11. for historical purposes only.
  12. ]
  13. An instance of [*Fields] is a container for holding HTTP header fields
  14. and their values. The implementation also calls upon the container to
  15. store the request target and non-standard strings for method and obsolete
  16. reason phrase as needed. Types which meet these requirements can always
  17. be serialized.
  18. [heading Associated Types]
  19. * [link beast.ref.boost__beast__http__is_fields `is_fields`]
  20. * __FieldsWriter__
  21. [heading Requirements]
  22. In this table:
  23. * `F` denotes a type that meets the requirements of [*Fields].
  24. * `W` denotes a type meeting the requirements of __FieldsWriter__.
  25. * `a` denotes a value of type `F`.
  26. * `c` denotes a (possibly const) value of type `F`.
  27. * `b` is a value of type `bool`
  28. * `n` is a value of type `boost::optional<std::uint64_t>`.
  29. * `s` is a value of type [link beast.ref.boost__beast__string_view `string_view`].
  30. * `v` is a value of type `unsigned int` representing the HTTP-version.
  31. [table Valid expressions
  32. [[Expression] [Type] [Semantics, Pre/Post-conditions]]
  33. [
  34. [`F::writer`]
  35. [`W`]
  36. [
  37. A type which meets the requirements of __FieldsWriter__.
  38. ]
  39. ][
  40. [`c.get_method_impl()`]
  41. [`string_view`]
  42. [
  43. Returns the method text.
  44. The implementation only calls this function for request
  45. headers when retrieving the method text previously set
  46. with a call to `set_method_impl` using a non-empty string.
  47. ]
  48. ][
  49. [`c.get_target_impl()`]
  50. [`string_view`]
  51. [
  52. Returns the target string.
  53. The implementation only calls this function for request headers.
  54. ]
  55. ][
  56. [`c.get_reason_impl()`]
  57. [`string_view`]
  58. [
  59. Returns the obsolete request text.
  60. The implementation only calls this for response headers when
  61. retrieving the reason text previously set with a call to
  62. `set_reason_impl` using a non-empty string.
  63. ]
  64. ][
  65. [`c.get_chunked_impl()`]
  66. [`bool`]
  67. [
  68. Returns `true` if the
  69. [@https://tools.ietf.org/html/rfc7230#section-3.3.1 [*Transfer-Encoding]]
  70. field value indicates that the payload is chunk encoded. Both
  71. of these conditions must be true:
  72. [itemized_list
  73. [
  74. The Transfer-Encoding field is present in the message.
  75. ][
  76. The last item in value of the field is "chunked".
  77. ]]
  78. ]
  79. ][
  80. [`c.get_keep_alive_impl(v)`]
  81. [`bool`]
  82. [
  83. Returns `true` if the semantics of the
  84. [@https://tools.ietf.org/html/rfc7230#section-6.1 [*Connection]]
  85. field and version indicate that the connection should remain
  86. open after the corresponding response is transmitted or received:
  87. [itemized_list
  88. [
  89. If `(v < 11)` the function returns `true` if the "keep-alive"
  90. token is present in the Connection field value. Otherwise the
  91. function returns `false`.
  92. ][
  93. If `(v == 11)`, the function returns `false` if the "close"
  94. token is present in the Connection field value. Otherwise the
  95. function returns `true`.
  96. ]]
  97. ]
  98. ][
  99. [`c.has_content_length()`]
  100. [`bool`]
  101. [
  102. Returns `true` if the
  103. [@https://tools.ietf.org/html/rfc7230#section-3.3.2 [*Content-Length]]
  104. field is present.
  105. ]
  106. ][
  107. [`a.set_method_impl(s)`]
  108. []
  109. [
  110. Stores a copy of `s` as the method text, or erases the previously
  111. stored value if `s` is empty.
  112. The implementation only calls this function for request headers.
  113. This function may throw `std::invalid_argument` if the operation
  114. is not supported by the container.
  115. ]
  116. ][
  117. [`a.set_target_impl(s)`]
  118. []
  119. [
  120. Stores a copy of `s` as the target, or erases the previously
  121. stored value if `s` is empty.
  122. The implementation only calls this function for request headers.
  123. This function may throw `std::invalid_argument` if the operation
  124. is not supported by the container.
  125. ]
  126. ][
  127. [`a.set_reason_impl(s)`]
  128. []
  129. [
  130. Stores a copy of `s` as the reason text, or erases the previously
  131. stored value of the reason text if `s` is empty.
  132. The implementation only calls this function for request headers.
  133. This function may throw `std::invalid_argument` if the operation
  134. is not supported by the container.
  135. ]
  136. ][
  137. [`a.set_chunked_impl(b)`]
  138. []
  139. [
  140. Adjusts the
  141. [@https://tools.ietf.org/html/rfc7230#section-3.3.1 [*Transfer-Encoding]]
  142. field value as follows:
  143. [itemized_list
  144. [
  145. If `b` is `true`, the "chunked" token is appended
  146. to the list of encodings if it does not already appear
  147. last in the list.
  148. If the Transfer-Encoding field is absent, the field will
  149. be inserted to the container with the value "chunked".
  150. ][
  151. If `b` is `false, the "chunked" token is removed from the
  152. list of encodings if it appears last in the list.
  153. If the result of the removal leaves the list of encodings
  154. empty, the Transfer-Encoding field shall not appear when
  155. the associated __FieldsWriter__ serializes the fields.
  156. ]]
  157. If the result of adjusting the field value produces an empty
  158. string, the field is removed from the container.
  159. ]
  160. ][
  161. [`a.set_content_length_impl(n)`]
  162. []
  163. [
  164. Adjusts the
  165. [@https://tools.ietf.org/html/rfc7230#section-3.3.2 [*Content-Length]]
  166. field value as follows:
  167. [itemized_list
  168. [
  169. If `n` contains a value, the Content-Length field
  170. will be set to the text representation of the value.
  171. Any previous Content-Length fields are removed from
  172. the container.
  173. ][
  174. If `n` does not contain a value, any present Content-Length
  175. fields are removed from the container.
  176. ]]
  177. ]
  178. ][
  179. [`a.set_keep_alive_impl(v,b)`]
  180. []
  181. [
  182. Adjusts the
  183. [@https://tools.ietf.org/html/rfc7230#section-6.1 [*Connection]]
  184. field value depending on the values of `v` and `b`. The field
  185. value is treated as
  186. [@https://tools.ietf.org/html/rfc7230#section-6.1 ['connection-option]]
  187. (rfc7230).
  188. [itemized_list
  189. [
  190. If `(v < 11 && b)`, then all "close" tokens present in the
  191. value are removed, and the "keep-alive" token is added to
  192. the value if it is not already present.
  193. ][
  194. If `(v < 11 && ! b)`, then all "close" and "keep-alive"
  195. tokens present in the value are removed.
  196. ][
  197. If `(v == 11 && b)`, then all "keep-alive" and "close"
  198. tokens present in the value are removed.
  199. ][
  200. If `(v == 11 && ! b)`, then all "keep-alive" tokens present
  201. in the value are removed, and the "close" token is added to
  202. the value if it is not already present.
  203. ]]
  204. If the result of adjusting the field value produces an empty
  205. string, the field is removed from the container.
  206. ]
  207. ]]
  208. [heading Exemplar]
  209. [concept_Fields]
  210. [heading Models]
  211. * [link beast.ref.boost__beast__http__basic_fields `basic_fields`]
  212. * [link beast.ref.boost__beast__http__fields `fields`]
  213. [endsect]