blob: 12b66c7f9dff5cf0ca187df8dbca9ae15bc5c1d0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include "cookies.h"
#include <library/cpp/string_utils/scan/scan.h>
#include <util/string/strip.h>
#include <util/string/builder.h>
namespace {
struct TCookiesScanner {
THttpCookies* C;
inline void operator()(const TStringBuf& key, const TStringBuf& val) {
C->Add(StripString(key), StripString(val));
}
};
}
void THttpCookies::Scan(const TStringBuf& s) {
Clear();
TCookiesScanner scan = {this};
ScanKeyValue<true, ';', '='>(s, scan);
}
/*** https://datatracker.ietf.org/doc/html/rfc6265#section-5.4 ***/
TString THttpCookies::ToString() const {
TStringBuilder result;
for (const auto& [key, value] : *this) {
if (!result.empty()) {
result << "; ";
}
result << key << "=" << value;
}
return result;
}
|