New HTTP interfaces (API Change):

fix #123
fix #154
fix #265

This completely replaces the HTTP parser used to read and
parse incoming messages. The new version is faster than
the old one, and written in fewer lines. A summary of
changes:

* parse and async_parse renamed to read and async_read

* basic_parser is optimized for linear buffers,
  use flat_streambuf for the best performance with these
  functions:

  - http::read
  - http::read_some
  - http::async_read
  - http::async_read_some

* The overloads of read() and async_read() which take
  just a header have been removed, since they would
  throw away important parse metadata.

* The derived class callbacks for basic_parser have
  been streamlined. All strings passed to callbacks
  are presented in their entirety, instead of being
  provided in pieces.

These changes allow use-cases that were previously
difficult or impossible, such as:

- Efficient relaying

- Late body type commitment

- Expect: 100-continue handling
This commit is contained in:
Vinnie Falco committed 2017-05-04 18:58:33 -07:00
1 parent f6835b8db4
commit f47b66179e
74 files changed
+7106 -5972

No files matched your search

+6 -5
View File
@@ -10,7 +10,7 @@
#include <beast/core/to_string.hpp>
#include <beast/http/fields.hpp>
#include <beast/http/parser_v1.hpp>
#include <beast/http/message_parser.hpp>
#include <beast/http/read.hpp>
#include <beast/http/write.hpp>
#include <beast/test/string_istream.hpp>
@@ -34,11 +34,12 @@ public:
"\r\n"
"xyz";
test::string_istream ss(ios_, s);
parser_v1<false, streambuf_body, fields> p;
message_parser<false, streambuf_body, fields> p;
streambuf sb;
parse(ss, sb, p);
BEAST_EXPECT(to_string(p.get().body.data()) == "xyz");
BEAST_EXPECT(boost::lexical_cast<std::string>(p.get()) == s);
read(ss, sb, p);
auto const& m = p.get();
BEAST_EXPECT(to_string(m.body.data()) == "xyz");
BEAST_EXPECT(boost::lexical_cast<std::string>(m) == s);
}
};