Refactor HTTP identifier names (API Change):

fix #171

Several names and  HTTP identifiers are renamed to be
more consistent, self-explanatory, and concise:

* "Fields" is a collection of HTTP header fields (rfc7230 section 3.2)
* "Header" is the Start Line plus Fields. Another way to look at it is,
  the HTTP message minus the body.
* `basic_fields` replaces `basic_headers`
* `fields` replaces `headers`
* `Fields` replaces `Headers` in template parameter lists
* `header` replaces `message_headers`
* `header::fields` replaces `message_headers::fields`

The changes are cosmetic and do not affect run-time behavior.
This commit is contained in:
Vinnie Falco
2016-11-15 12:04:44 -05:00
parent 79be7f8b39
commit a0a335972f
64 changed files with 1220 additions and 1125 deletions
+22 -22
View File
@@ -9,8 +9,8 @@
#include <beast/http/parser_v1.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/http/headers.hpp>
#include <beast/http/headers_parser_v1.hpp>
#include <beast/http/fields.hpp>
#include <beast/http/header_parser_v1.hpp>
#include <beast/http/parse.hpp>
#include <beast/http/string_body.hpp>
#include <beast/test/string_stream.hpp>
@@ -32,7 +32,7 @@ public:
// consecutive empty header values
{
error_code ec;
parser_v1<true, string_body, headers> p;
parser_v1<true, string_body, fields> p;
std::string const s =
"GET / HTTP/1.1\r\n"
"X1:\r\n"
@@ -44,12 +44,12 @@ public:
return;
BEAST_EXPECT(p.complete());
auto const msg = p.release();
BEAST_EXPECT(msg.headers.exists("X1"));
BEAST_EXPECT(msg.headers["X1"] == "");
BEAST_EXPECT(msg.headers.exists("X2"));
BEAST_EXPECT(msg.headers["X2"] == "");
BEAST_EXPECT(msg.headers.exists("X3"));
BEAST_EXPECT(msg.headers["X3"] == "x");
BEAST_EXPECT(msg.fields.exists("X1"));
BEAST_EXPECT(msg.fields["X1"] == "");
BEAST_EXPECT(msg.fields.exists("X2"));
BEAST_EXPECT(msg.fields["X2"] == "");
BEAST_EXPECT(msg.fields.exists("X3"));
BEAST_EXPECT(msg.fields["X3"] == "x");
}
}
@@ -62,23 +62,23 @@ public:
"\r\n"
"*"};
streambuf rb;
headers_parser_v1<true, headers> p0;
header_parser_v1<true, fields> p0;
parse(ss, rb, p0);
request_headers const& reqh = p0.get();
request_header const& reqh = p0.get();
BEAST_EXPECT(reqh.method == "GET");
BEAST_EXPECT(reqh.url == "/");
BEAST_EXPECT(reqh.version == 11);
BEAST_EXPECT(reqh.headers["User-Agent"] == "test");
BEAST_EXPECT(reqh.headers["Content-Length"] == "1");
parser_v1<true, string_body, headers> p =
BEAST_EXPECT(reqh.fields["User-Agent"] == "test");
BEAST_EXPECT(reqh.fields["Content-Length"] == "1");
parser_v1<true, string_body, fields> p =
with_body<string_body>(p0);
BEAST_EXPECT(p.get().method == "GET");
BEAST_EXPECT(p.get().url == "/");
BEAST_EXPECT(p.get().version == 11);
BEAST_EXPECT(p.get().headers["User-Agent"] == "test");
BEAST_EXPECT(p.get().headers["Content-Length"] == "1");
BEAST_EXPECT(p.get().fields["User-Agent"] == "test");
BEAST_EXPECT(p.get().fields["Content-Length"] == "1");
parse(ss, rb, p);
request<string_body, headers> req = p.release();
request<string_body, fields> req = p.release();
BEAST_EXPECT(req.body == "*");
}
@@ -88,7 +88,7 @@ public:
{
error_code ec;
parser_v1<true, string_body,
basic_headers<std::allocator<char>>> p;
basic_fields<std::allocator<char>>> p;
std::string const s =
"GET / HTTP/1.1\r\n"
"User-Agent: test\r\n"
@@ -102,13 +102,13 @@ public:
BEAST_EXPECT(m.method == "GET");
BEAST_EXPECT(m.url == "/");
BEAST_EXPECT(m.version == 11);
BEAST_EXPECT(m.headers["User-Agent"] == "test");
BEAST_EXPECT(m.fields["User-Agent"] == "test");
BEAST_EXPECT(m.body == "*");
}
{
error_code ec;
parser_v1<false, string_body,
basic_headers<std::allocator<char>>> p;
basic_fields<std::allocator<char>>> p;
std::string const s =
"HTTP/1.1 200 OK\r\n"
"Server: test\r\n"
@@ -122,13 +122,13 @@ public:
BEAST_EXPECT(m.status == 200);
BEAST_EXPECT(m.reason == "OK");
BEAST_EXPECT(m.version == 11);
BEAST_EXPECT(m.headers["Server"] == "test");
BEAST_EXPECT(m.fields["Server"] == "test");
BEAST_EXPECT(m.body == "*");
}
// skip body
{
error_code ec;
parser_v1<false, string_body, headers> p;
parser_v1<false, string_body, fields> p;
std::string const s =
"HTTP/1.1 200 Connection Established\r\n"
"Proxy-Agent: Zscaler/5.1\r\n"