diff --git a/CHANGELOG.md b/CHANGELOG.md index ddaa6efd..cc2e7caa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Version 61: * Tidy up some integer conversion warnings * Add message::header_part() +API Changes: + +* header::version is unsigned + -------------------------------------------------------------------------------- Version 60: diff --git a/doc/concept/FieldsReader.qbk b/doc/concept/FieldsReader.qbk index aae62cd3..3a8e52d8 100644 --- a/doc/concept/FieldsReader.qbk +++ b/doc/concept/FieldsReader.qbk @@ -23,9 +23,9 @@ In this table: * `f` is a value of type `F`. -* `v` is an integer representing the HTTP version. +* `v` is an `unsigned` value representing the HTTP version. -* `c` is an integer representing the HTTP status-code. +* `c` is an `unsigned` representing the HTTP status-code. * `m` is a value of type [link beast.ref.beast__http__verb `verb`]. @@ -75,4 +75,23 @@ In this table: ] ] +Exemplar: +``` +struct FieldsReader +{ + // The type of buffers returned by `get` + using const_buffers_type = implementation-defined; + + // Constructor for requests + FieldsReader(F const& f, unsigned version, verb method); + + // Constructor for responses + FieldsReader(F const& f, unsigned version, unsigned status); + + // Returns the serialized header buffers + const_buffers_type + get(); +}; +``` + [endsect] diff --git a/doc/images/message.png b/doc/images/message.png index 0ee1fe6e..e78bbcb0 100644 Binary files a/doc/images/message.png and b/doc/images/message.png differ diff --git a/include/beast/http/impl/fields.ipp b/include/beast/http/impl/fields.ipp index 9493873f..0e2d7013 100644 --- a/include/beast/http/impl/fields.ipp +++ b/include/beast/http/impl/fields.ipp @@ -135,12 +135,12 @@ public: template void prepare(String& s, basic_fields const& f, - int version, verb v); + unsigned version, verb v); template void prepare(String&s, basic_fields const& f, - int version, int code); + unsigned version, int code); basic_fields const& f_; static_string ss_; @@ -154,9 +154,11 @@ public: field_range, boost::asio::const_buffers_1>; - reader(basic_fields const& f, int version, verb v); + reader(basic_fields const& f, + unsigned version, verb v); - reader(basic_fields const& f, int version, int code); + reader(basic_fields const& f, + unsigned version, int code); const_buffers_type get() const @@ -173,7 +175,7 @@ template void basic_fields::reader:: prepare(String& s, basic_fields const& f, - int version, verb v) + unsigned version, verb v) { if(v == verb::unknown) { @@ -214,7 +216,7 @@ template void basic_fields::reader:: prepare(String& s,basic_fields const& f, - int version, int code) + unsigned version, int code) { if(version == 11) { @@ -253,7 +255,8 @@ prepare(String& s,basic_fields const& f, template basic_fields::reader:: -reader(basic_fields const& f, int version, verb v) +reader(basic_fields const& f, + unsigned version, verb v) : f_(f) { try @@ -270,7 +273,8 @@ reader(basic_fields const& f, int version, verb v) template basic_fields::reader:: -reader(basic_fields const& f, int version, int code) +reader(basic_fields const& f, + unsigned version, int code) : f_(f) { try diff --git a/include/beast/http/message.hpp b/include/beast/http/message.hpp index e9a1d028..1a39c757 100644 --- a/include/beast/http/message.hpp +++ b/include/beast/http/message.hpp @@ -63,13 +63,13 @@ struct header : Fields This holds both the major and minor version numbers, using these formulas: @code - int major = version / 10; - int minor = version % 10; + unsigned major = version / 10; + unsigned minor = version % 10; @endcode Newly constructed headers will use HTTP/1.1 by default. */ - int version = 11; + unsigned version = 11; /// Default constructor header() = default; @@ -207,13 +207,13 @@ struct header : Fields This holds both the major and minor version numbers, using these formulas: @code - major = version / 10; - minor = version % 10; + unsigned major = version / 10; + unsigned minor = version % 10; @endcode Newly constructed headers will use HTTP/1.1 by default. */ - int version = 11; + unsigned version = 11; /// Default constructor. header() = default;