Refactor header status, reason, and target (API Change):

* header::result is a family of functions to replace header::status

* header interface now uses status enum and also ints

* reason-phrase is no longer stored unless the user explicitly
  requests it.

* When serializing, the standard reason is used for the
  corresponding status code unless the user has changed it.
This commit is contained in:
Vinnie Falco
2017-06-04 17:26:20 -07:00
parent 60f044aff0
commit e67c0abe79
31 changed files with 588 additions and 220 deletions
+1 -2
View File
@@ -147,8 +147,7 @@ objects:
```
response<string_body> res;
res.version = 11; // HTTP/1.1
res.status = 200;
res.reason("OK");
res.result(status::ok);
res.body = "Hello, world!";
res.fields.insert("Server", "Beast");
res.fields.insert("Content-Length", res.body.size());
+1 -2
View File
@@ -128,8 +128,7 @@ the number of octets received prior to the server closing the connection:
{
response<string_body> res;
res.version = 11;
res.status = 200;
res.reason("OK");
res.result(status::ok);
res.fields.insert("Server", "Beast");
res.body = "Hello, world!";
+2 -2
View File
@@ -164,7 +164,7 @@ send_expect_100_continue(
{
response<string_body> res;
read(stream, buffer, res);
if(res.status != 100)
if(res.result() != status::continue_)
{
// The server indicated that it will not
// accept the request, so skip sending the body.
@@ -229,7 +229,7 @@ send_cgi_response(
// allowing serialization to use manually provided buffers.
message<false, buffer_body, fields> res;
res.status = 200;
res.result(status::ok);
res.version = 11;
res.fields.insert("Server", "Beast");
res.fields.insert("Transfer-Encoding", "chunked");
+1 -2
View File
@@ -197,8 +197,7 @@ receive_expect_100_continue(
// send 100 response
response<empty_body> res;
res.version = 11;
res.status = 100;
res.reason("Continue");
res.result(status::continue_);
res.fields.insert("Server", "test");
write(stream, res, ec);
if(ec)
+1 -1
View File
@@ -56,7 +56,7 @@ class custom_parser
/// Called after receiving the start-line (isRequest == false).
void
on_response(
int status, // The status-code
int code, // The status-code
string_view reason, // The obsolete reason-phrase
int version, // The HTTP-version
error_code& ec); // The error returned to the caller, if any
+2 -2
View File
@@ -256,13 +256,13 @@ struct header<false, Fields>
string_view
reason() const
{
return fields.reason();
return fields.reason_impl();
}
void
reason(string_view s)
{
fields.reason(s);
fields.reason_impl(s);
}
Fields fields;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.
+1
View File
@@ -88,6 +88,7 @@
<member><link linkend="beast.ref.http__connection">connection</link></member>
<member><link linkend="beast.ref.http__error">error</link></member>
<member><link linkend="beast.ref.http__status">status</link></member>
<member><link linkend="beast.ref.http__status_class">status_class</link></member>
<member><link linkend="beast.ref.http__verb">verb</link></member>
</simplelist>
<bridgehead renderas="sect3">Type Traits</bridgehead>