Commit 43e1b4d5 authored by 's avatar

Fix Whitespace

parent 6b8cdfa3
...@@ -212,32 +212,32 @@ CookieJar::add(const Cookie& cookie) { ...@@ -212,32 +212,32 @@ CookieJar::add(const Cookie& cookie) {
void void
CookieJar::addFromRaw(const char *str, size_t len) { CookieJar::addFromRaw(const char *str, size_t len) {
RawStreamBuf<> buf(const_cast<char *>(str), len); RawStreamBuf<> buf(const_cast<char *>(str), len);
StreamCursor cursor(&buf); StreamCursor cursor(&buf);
while (!cursor.eof()) { while (!cursor.eof()) {
StreamCursor::Token nameToken(cursor); StreamCursor::Token nameToken(cursor);
if (!match_until('=', cursor)) if (!match_until('=', cursor))
throw std::runtime_error("Invalid cookie, missing value"); throw std::runtime_error("Invalid cookie, missing value");
auto name = nameToken.text(); auto name = nameToken.text();
if (!cursor.advance(1)) if (!cursor.advance(1))
throw std::runtime_error("Invalid cookie, missing value"); throw std::runtime_error("Invalid cookie, missing value");
StreamCursor::Token valueToken(cursor); StreamCursor::Token valueToken(cursor);
match_until(';', cursor); match_until(';', cursor);
auto value = valueToken.text(); auto value = valueToken.text();
Cookie cookie(std::move(name), std::move(value)); Cookie cookie(std::move(name), std::move(value));
add(cookie); add(cookie);
cursor.advance(1); cursor.advance(1);
skip_whitespaces(cursor); skip_whitespaces(cursor);
} }
} }
Cookie Cookie
CookieJar::get(const std::string& name) const { CookieJar::get(const std::string& name) const {
......
...@@ -294,7 +294,7 @@ namespace Private { ...@@ -294,7 +294,7 @@ namespace Private {
} }
if (name == "Cookie") { if (name == "Cookie") {
message->cookies_.addFromRaw(cursor.offset(start), cursor.diff(start)); message->cookies_.addFromRaw(cursor.offset(start), cursor.diff(start));
} }
else if (Header::Registry::isRegistered(name)) { else if (Header::Registry::isRegistered(name)) {
......
...@@ -137,14 +137,14 @@ void addCookies(const char* str, std::function<void (const CookieJar&)> testFunc ...@@ -137,14 +137,14 @@ void addCookies(const char* str, std::function<void (const CookieJar&)> testFunc
TEST(cookie_test, cookiejar_test) { TEST(cookie_test, cookiejar_test) {
addCookies("key1=value1", [](const CookieJar& jar) { addCookies("key1=value1", [](const CookieJar& jar) {
ASSERT_EQ(jar.get("key1").value, "value1"); ASSERT_EQ(jar.get("key1").value, "value1");
}); });
addCookies("key2=value2; key3=value3", [](const CookieJar& jar) { addCookies("key2=value2; key3=value3", [](const CookieJar& jar) {
ASSERT_EQ(jar.get("key2").value, "value2"); ASSERT_EQ(jar.get("key2").value, "value2");
ASSERT_EQ(jar.get("key3").value, "value3"); ASSERT_EQ(jar.get("key3").value, "value3");
}); });
CookieJar jar; CookieJar jar;
ASSERT_THROW(jar.addFromRaw("key4", strlen("key4")), std::runtime_error); ASSERT_THROW(jar.addFromRaw("key4", strlen("key4")), std::runtime_error);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment