Clear previous message fields in parser

fix #818
This commit is contained in:
Vinnie Falco
2017-10-16 12:09:41 -07:00
parent e832baf93f
commit 2399b610e3
4 changed files with 22 additions and 3 deletions
+15
View File
@@ -21,6 +21,7 @@
#include <boost/beast/http/read.hpp>
#include <boost/beast/http/string_body.hpp>
#include <boost/system/system_error.hpp>
#include <algorithm>
namespace boost {
namespace beast {
@@ -329,6 +330,19 @@ public:
BEAST_EXPECT(used == 0);
}
void
testIssue818()
{
// Make sure that the parser clears pre-existing fields
request<string_body> m;
m.set(field::accept, "html/text");
BEAST_EXPECT(std::distance(m.begin(), m.end()) == 1);
request_parser<string_body> p{std::move(m)};
BEAST_EXPECT(std::distance(m.begin(), m.end()) == 0);
auto& m1 = p.get();
BEAST_EXPECT(std::distance(m1.begin(), m1.end()) == 0);
}
void
run() override
{
@@ -336,6 +350,7 @@ public:
testNeedMore<flat_buffer>();
testNeedMore<multi_buffer>();
testGotSome();
testIssue818();
}
};