src/xs/protocol/http.cc

filter: Statementstmt 0.0% 0 / 181 Branchbran 0.0% 0 / 470 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 651 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/arch/Protocol/HTTP/ResponseParser.pm ↑ Summary src/xs/protocol/http.h »
1 #include "http.h"
2 #include <cstring>
3 #include <xs/date.h>
4  
5 namespace xs { namespace protocol { namespace http {
6  
7 using panda::string;
8  
9 0 static inline void msgfill (Message* m, const Hash& h) {
10 0 ▶ for (auto& row : h) {
Branch: 2 branches
BranchTrueFalseTotal
for (auto& row : h) { 0 0 0
for (auto& row : h) { 0 0 0
11 0 ▶ auto key = row.key();
Branch: 1 branch
BranchTrueFalseTotal
auto key = row.key(); 0 0 0
12 0 ▶ if (!key.length()) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!key.length()) continue; 0 0 0
13 0 ▶ auto v = row.value();
Branch: 1 branch
BranchTrueFalseTotal
auto v = row.value(); 0 0 0
14 0 switch (key[0]) {
15 0 case 'h':
16 0 ▶ if (key == "headers") set_headers(m, v);
Branch: 4 branches
BranchTrueFalseTotal
if (key == "headers") set_headers(m, v); 0 0 0
if (key == "headers") set_headers(m, v); 0 0 0
if (key == "headers") set_headers(m, v); 0 0 0
if (key == "headers") set_headers(m, v); 0 0 0
17 0 ▶ else if (key == "http_version") m->http_version = xs::in<int>(v);
Branch: 3 branches
BranchTrueFalseTotal
else if (key == "http_version") m->http_version = xs::in<int>(v); 0 0 0
else if (key == "http_version") m->http_version = xs::in<int>(v); 0 0 0
else if (key == "http_version") m->http_version = xs::in<int>(v); 0 0 0
18 0 break;
19 0 case 'b':
20 0 ▶ if (key == "body") m->body = xs::in<string>(v);
Branch: 4 branches
BranchTrueFalseTotal
if (key == "body") m->body = xs::in<string>(v); 0 0 0
if (key == "body") m->body = xs::in<string>(v); 0 0 0
if (key == "body") m->body = xs::in<string>(v); 0 0 0
if (key == "body") m->body = xs::in<string>(v); 0 0 0
21 0 break;
22 0 case 'c':
23 0 ▶ if (key == "chunked") m->chunked = v.is_true();
Branch: 3 branches
BranchTrueFalseTotal
if (key == "chunked") m->chunked = v.is_true(); 0 0 0
if (key == "chunked") m->chunked = v.is_true(); 0 0 0
if (key == "chunked") m->chunked = v.is_true(); 0 0 0
24 0 ▶ else if (key == "compress") {
Branch: 2 branches
BranchTrueFalseTotal
else if (key == "compress") { 0 0 0
else if (key == "compress") { 0 0 0
25 0 ▶ if (v.is_array_ref()) {
Branch: 2 branches
BranchTrueFalseTotal
if (v.is_array_ref()) { 0 0 0
if (v.is_array_ref()) { 0 0 0
26 0 ▶ Array a(v);
Branch: 1 branch
BranchTrueFalseTotal
Array a(v); 0 0 0
27 0 ▶ switch (a.size()) {
Branch: 1 branch
BranchTrueFalseTotal
switch (a.size()) { 0 0 0
28 0 ▶ case 2: m->compression.level = (Compression::Level)SvIV(a[1]);
Branch: 2 branches
BranchTrueFalseTotal
case 2: m->compression.level = (Compression::Level)SvIV(a[1]); 0 0 0
case 2: m->compression.level = (Compression::Level)SvIV(a[1]); 0 0 0
29 // fall through
30 0 ▶ case 1: m->compression.type = (Compression::Type)SvIV(a[0]);
Branch: 2 branches
BranchTrueFalseTotal
case 1: m->compression.type = (Compression::Type)SvIV(a[0]); 0 0 0
case 1: m->compression.type = (Compression::Type)SvIV(a[0]); 0 0 0
31 }
32 0 }
33 0 ▶ else m->compression.type = (Compression::Type)SvIV(v);
Branch: 1 branch
BranchTrueFalseTotal
else m->compression.type = (Compression::Type)SvIV(v); 0 0 0
34 }
35 0 break;
36 }
37 0 }
38 0 }
39  
40 0 static Request::EncType get_encoding(const Sv& sv) {
41 using Type = Request::EncType;
42 0 int val = SvIV(sv);
43 0 ▶ if (val < (int)Type::Multipart || val > (int)Type::UrlEncoded) throw "invalid form encoding";
Branch: 2 branches
BranchTrueFalseTotal
if (val < (int)Type::Multipart || val > (int)Type::UrlEncoded) throw "invalid form encoding"; 0 0 0
if (val < (int)Type::Multipart || val > (int)Type::UrlEncoded) throw "invalid form encoding"; 0 0 0
44 0 return (Type)val;
45 }
46  
47 0 static void fill(Request::Form& form, Array& arr, Request::EncType enc_type) {
48 0 ▶ if (arr.size()) {
Branch: 1 branch
BranchTrueFalseTotal
if (arr.size()) { 0 0 0
49 0 form.enc_type(enc_type);
50 0 bool even = arr.size() % 2 == 0;
51 0 ▶ size_t last = even ? arr.size() - 1 : arr.size() - 2;
Branch: 1 branch
BranchTrueFalseTotal
size_t last = even ? arr.size() - 1 : arr.size() - 2; 0 0 0
52 0 ▶ for(size_t i = 0; i < last; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for(size_t i = 0; i < last; i += 2) { 0 0 0
53 0 ▶ string key = arr.at(i).as_string();
Branch: 2 branches
BranchTrueFalseTotal
string key = arr.at(i).as_string(); 0 0 0
string key = arr.at(i).as_string(); 0 0 0
54 0 ▶ auto value = arr.at(i +1);
Branch: 1 branch
BranchTrueFalseTotal
auto value = arr.at(i +1); 0 0 0
55 0 ▶ if(value.is_array_ref()) {
Branch: 2 branches
BranchTrueFalseTotal
if(value.is_array_ref()) { 0 0 0
if(value.is_array_ref()) { 0 0 0
56 0 ▶ auto values = Array(value);
Branch: 1 branch
BranchTrueFalseTotal
auto values = Array(value); 0 0 0
57 0 ▶ if (values.size() != 3) {
Branch: 2 branches
BranchTrueFalseTotal
if (values.size() != 3) { 0 0 0
if (values.size() != 3) { 0 0 0
58 0 string err = "invalid file fieild '";
59 0 ▶ err += key;
Branch: 1 branch
BranchTrueFalseTotal
err += key; 0 0 0
60 0 ▶ err += ": it should be array [$filename => $filecontent, $filetype]";
Branch: 1 branch
BranchTrueFalseTotal
err += ": it should be array [$filename => $filecontent, $filetype]"; 0 0 0
61 0 ▶ throw err;
Branch: 1 branch
BranchTrueFalseTotal
throw err; 0 0 0
62 }
63 0 ▶ form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string());
Branch: 7 branches
BranchTrueFalseTotal
form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string()); 0 0 0
form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string()); 0 0 0
form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string()); 0 0 0
form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string()); 0 0 0
form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string()); 0 0 0
form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string()); 0 0 0
form.add(key, values[1].as_string(), values[0].as_string(), values[2].as_string()); 0 0 0
64 0 }
65 else {
66 0 ▶ form.add(key, value.as_string());
Branch: 2 branches
BranchTrueFalseTotal
form.add(key, value.as_string()); 0 0 0
form.add(key, value.as_string()); 0 0 0
67 }
68 0 }
69 0 ▶ if (!even) {
Branch: 1 branch
BranchTrueFalseTotal
if (!even) { 0 0 0
70 0 ▶ string key = arr.back().as_string();
Branch: 2 branches
BranchTrueFalseTotal
string key = arr.back().as_string(); 0 0 0
string key = arr.back().as_string(); 0 0 0
71 0 ▶ form.add(key, "");
Branch: 1 branch
BranchTrueFalseTotal
form.add(key, ""); 0 0 0
72 0 }
73 }
74 0 }
75  
76 0 void fill_form(Request* req, const Sv& sv) {
77 0 ▶ if (!sv || !sv.defined()) return;
Branch: 3 branches
BranchTrueFalseTotal
if (!sv || !sv.defined()) return; 0 0 0
if (!sv || !sv.defined()) return; 0 0 0
if (!sv || !sv.defined()) return; 0 0 0
78 0 auto& form = req->form;
79 0 ▶ if (sv.is_hash_ref()) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv.is_hash_ref()) { 0 0 0
80 0 ▶ Hash h(sv);
Branch: 1 branch
BranchTrueFalseTotal
Hash h(sv); 0 0 0
81 0 ▶ Request::EncType type = h.exists("enc_type") ? get_encoding(h.fetch("enc_type")) : Request::EncType::Multipart;
Branch: 6 branches
BranchTrueFalseTotal
Request::EncType type = h.exists("enc_type") ? get_encoding(h.fetch("enc_type")) : Request::EncType::Multipart; 0 0 0
Request::EncType type = h.exists("enc_type") ? get_encoding(h.fetch("enc_type")) : Request::EncType::Multipart; 0 0 0
Request::EncType type = h.exists("enc_type") ? get_encoding(h.fetch("enc_type")) : Request::EncType::Multipart; 0 0 0
Request::EncType type = h.exists("enc_type") ? get_encoding(h.fetch("enc_type")) : Request::EncType::Multipart; 0 0 0
Request::EncType type = h.exists("enc_type") ? get_encoding(h.fetch("enc_type")) : Request::EncType::Multipart; 0 0 0
Request::EncType type = h.exists("enc_type") ? get_encoding(h.fetch("enc_type")) : Request::EncType::Multipart; 0 0 0
82 0 Sv fields;
83 0 ▶ if ((fields = h.fetch("fields"))) {
Branch: 2 branches
BranchTrueFalseTotal
if ((fields = h.fetch("fields"))) { 0 0 0
if ((fields = h.fetch("fields"))) { 0 0 0
84 0 ▶ Array arr(fields);
Branch: 1 branch
BranchTrueFalseTotal
Array arr(fields); 0 0 0
85 0 ▶ fill(form, arr, type);
Branch: 1 branch
BranchTrueFalseTotal
fill(form, arr, type); 0 0 0
86 0 }
87 0 else form.enc_type(type);
88 0 }
89 0 ▶ else if (sv.is_array_ref()) {
Branch: 1 branch
BranchTrueFalseTotal
else if (sv.is_array_ref()) { 0 0 0
90 0 ▶ Array arr(sv);
Branch: 1 branch
BranchTrueFalseTotal
Array arr(sv); 0 0 0
91 0 ▶ fill(form, arr, Request::EncType::Multipart);
Branch: 1 branch
BranchTrueFalseTotal
fill(form, arr, Request::EncType::Multipart); 0 0 0
92 0 }
93 0 else form.enc_type(get_encoding(sv));
94 }
95  
96  
97 0 void fill (Request* req, const Hash& h) {
98 0 msgfill(req, h);
99 0 ▶ for (auto& row : h) {
Branch: 2 branches
BranchTrueFalseTotal
for (auto& row : h) { 0 0 0
for (auto& row : h) { 0 0 0
100 0 ▶ auto key = row.key();
Branch: 1 branch
BranchTrueFalseTotal
auto key = row.key(); 0 0 0
101 0 ▶ if (!key.length()) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!key.length()) continue; 0 0 0
102 0 ▶ auto v = row.value();
Branch: 1 branch
BranchTrueFalseTotal
auto v = row.value(); 0 0 0
103 0 switch (key[0]) {
104 0 case 'm':
105 0 ▶ if (key == "method") { if (v.defined()) set_method(req, v); }
Branch: 5 branches
BranchTrueFalseTotal
if (key == "method") { if (v.defined()) set_method(req, v); } 0 0 0
if (key == "method") { if (v.defined()) set_method(req, v); } 0 0 0
if (key == "method") { if (v.defined()) set_method(req, v); } 0 0 0
if (key == "method") { if (v.defined()) set_method(req, v); } 0 0 0
if (key == "method") { if (v.defined()) set_method(req, v); } 0 0 0
106 0 break;
107 0 case 'u':
108 0 ▶ if (key == "uri") req->uri = xs::in<URISP>(v);
Branch: 3 branches
BranchTrueFalseTotal
if (key == "uri") req->uri = xs::in<URISP>(v); 0 0 0
if (key == "uri") req->uri = xs::in<URISP>(v); 0 0 0
if (key == "uri") req->uri = xs::in<URISP>(v); 0 0 0
109 0 break;
110 0 case 'c':
111 0 ▶ if (key == "cookies") set_request_cookies(req, v);
Branch: 4 branches
BranchTrueFalseTotal
if (key == "cookies") set_request_cookies(req, v); 0 0 0
if (key == "cookies") set_request_cookies(req, v); 0 0 0
if (key == "cookies") set_request_cookies(req, v); 0 0 0
if (key == "cookies") set_request_cookies(req, v); 0 0 0
112 0 break;
113 0 case 'a':
114 0 ▶ if (key == "allow_compression") {
Branch: 2 branches
BranchTrueFalseTotal
if (key == "allow_compression") { 0 0 0
if (key == "allow_compression") { 0 0 0
115 0 ▶ if (v.is_array_ref()) {
Branch: 2 branches
BranchTrueFalseTotal
if (v.is_array_ref()) { 0 0 0
if (v.is_array_ref()) { 0 0 0
116 0 ▶ Array av(v);
Branch: 1 branch
BranchTrueFalseTotal
Array av(v); 0 0 0
117 0 ▶ for (auto value : av) {
Branch: 4 branches
BranchTrueFalseTotal
for (auto value : av) { 0 0 0
for (auto value : av) { 0 0 0
for (auto value : av) { 0 0 0
for (auto value : av) { 0 0 0
118 0 ▶ auto val = value.as_number<uint8_t>();
Branch: 1 branch
BranchTrueFalseTotal
auto val = value.as_number<uint8_t>(); 0 0 0
119 0 ▶ if (is_valid_compression(val)) req->allow_compression((Compression::Type)val);
Branch: 2 branches
BranchTrueFalseTotal
if (is_valid_compression(val)) req->allow_compression((Compression::Type)val); 0 0 0
if (is_valid_compression(val)) req->allow_compression((Compression::Type)val); 0 0 0
120 0 }
121 0 }
122 else {
123 0 ▶ uint8_t val = SvIV(v);
Branch: 1 branch
BranchTrueFalseTotal
uint8_t val = SvIV(v); 0 0 0
124 0 ▶ if (is_valid_compression(val)) req->allow_compression((Compression::Type)val);
Branch: 2 branches
BranchTrueFalseTotal
if (is_valid_compression(val)) req->allow_compression((Compression::Type)val); 0 0 0
if (is_valid_compression(val)) req->allow_compression((Compression::Type)val); 0 0 0
125 }
126 }
127 0 break;
128 }
129 0 }
130 0 }
131  
132 0 void fill (Response* res, const Hash& h) {
133 0 msgfill(res, h);
134 0 ▶ for (auto& row : h) {
Branch: 2 branches
BranchTrueFalseTotal
for (auto& row : h) { 0 0 0
for (auto& row : h) { 0 0 0
135 0 ▶ auto key = row.key();
Branch: 1 branch
BranchTrueFalseTotal
auto key = row.key(); 0 0 0
136 0 ▶ if (!key.length()) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!key.length()) continue; 0 0 0
137 0 ▶ auto v = row.value();
Branch: 1 branch
BranchTrueFalseTotal
auto v = row.value(); 0 0 0
138 0 switch (key[0]) {
139 0 case 'c':
140 0 ▶ if (key == "code") res->code = v.as_number<int>();
Branch: 3 branches
BranchTrueFalseTotal
if (key == "code") res->code = v.as_number<int>(); 0 0 0
if (key == "code") res->code = v.as_number<int>(); 0 0 0
if (key == "code") res->code = v.as_number<int>(); 0 0 0
141 0 ▶ else if (key == "cookies") set_response_cookies(res, v);
Branch: 4 branches
BranchTrueFalseTotal
else if (key == "cookies") set_response_cookies(res, v); 0 0 0
else if (key == "cookies") set_response_cookies(res, v); 0 0 0
else if (key == "cookies") set_response_cookies(res, v); 0 0 0
else if (key == "cookies") set_response_cookies(res, v); 0 0 0
142 0 break;
143 0 case 'm':
144 0 ▶ if (key == "message") res->message = v.as_string();
Branch: 4 branches
BranchTrueFalseTotal
if (key == "message") res->message = v.as_string(); 0 0 0
if (key == "message") res->message = v.as_string(); 0 0 0
if (key == "message") res->message = v.as_string(); 0 0 0
if (key == "message") res->message = v.as_string(); 0 0 0
145 0 break;
146 }
147 0 }
148 0 }
149  
150 0 void set_headers (Message* p, const Hash& hv) {
151 0 p->headers.clear();
152 0 ▶ for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value()));
Branch: 7 branches
BranchTrueFalseTotal
for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->headers.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
153 0 }
154  
155 0 void set_method (Request* req, const Sv& method) {
156 using Method = Request::Method;
157 0 int num = SvIV_nomg(method);
158 0 ▶ if (num < (int)Method::Options || num > (int)Method::Connect) throw panda::exception("invalid http method");
Branch: 2 branches
BranchTrueFalseTotal
if (num < (int)Method::Options || num > (int)Method::Connect) throw panda::exception("invalid http method"); 0 0 0
if (num < (int)Method::Options || num > (int)Method::Connect) throw panda::exception("invalid http method"); 0 0 0
159 0 req->method_raw((Method)num);
160 0 }
161  
162 0 void set_request_cookies (Request* p, const Hash& hv) {
163 0 p->cookies.clear();
164 0 ▶ for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value()));
Branch: 7 branches
BranchTrueFalseTotal
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<string>(row.value())); 0 0 0
165 0 }
166  
167 0 void set_response_cookies (Response* p, const Hash& hv) {
168 0 p->cookies.clear();
169 0 ▶ for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value()));
Branch: 7 branches
BranchTrueFalseTotal
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value())); 0 0 0
for (const auto& row : hv) p->cookies.add(string(row.key()), xs::in<Response::Cookie>(row.value())); 0 0 0
170 0 }
171  
172 }}}
173  
174 namespace xs {
175  
176 using Response = panda::protocol::http::Response;
177 using CookieJar = panda::protocol::http::CookieJar;
178  
179 0 Response::Cookie Typemap<Response::Cookie>::in (const Hash& h) {
180 0 ▶ Response::Cookie c;
Branch: 1 branch
BranchTrueFalseTotal
Response::Cookie c; 0 0 0
181 0 Scalar v;
182 0 ▶ if ((v = h.fetch("value"))) c.value(v.as_string());
Branch: 4 branches
BranchTrueFalseTotal
if ((v = h.fetch("value"))) c.value(v.as_string()); 0 0 0
if ((v = h.fetch("value"))) c.value(v.as_string()); 0 0 0
if ((v = h.fetch("value"))) c.value(v.as_string()); 0 0 0
if ((v = h.fetch("value"))) c.value(v.as_string()); 0 0 0
183 0 ▶ if ((v = h.fetch("domain"))) c.domain(v.as_string());
Branch: 4 branches
BranchTrueFalseTotal
if ((v = h.fetch("domain"))) c.domain(v.as_string()); 0 0 0
if ((v = h.fetch("domain"))) c.domain(v.as_string()); 0 0 0
if ((v = h.fetch("domain"))) c.domain(v.as_string()); 0 0 0
if ((v = h.fetch("domain"))) c.domain(v.as_string()); 0 0 0
184 0 ▶ if ((v = h.fetch("path"))) c.path(v.as_string());
Branch: 4 branches
BranchTrueFalseTotal
if ((v = h.fetch("path"))) c.path(v.as_string()); 0 0 0
if ((v = h.fetch("path"))) c.path(v.as_string()); 0 0 0
if ((v = h.fetch("path"))) c.path(v.as_string()); 0 0 0
if ((v = h.fetch("path"))) c.path(v.as_string()); 0 0 0
185 0 ▶ if ((v = h.fetch("expires"))) c.expires(xs::in<panda::date::Date>(v));
Branch: 4 branches
BranchTrueFalseTotal
if ((v = h.fetch("expires"))) c.expires(xs::in<panda::date::Date>(v)); 0 0 0
if ((v = h.fetch("expires"))) c.expires(xs::in<panda::date::Date>(v)); 0 0 0
if ((v = h.fetch("expires"))) c.expires(xs::in<panda::date::Date>(v)); 0 0 0
if ((v = h.fetch("expires"))) c.expires(xs::in<panda::date::Date>(v)); 0 0 0
186 0 ▶ if ((v = h.fetch("max_age"))) c.max_age(v.as_number<uint64_t>());
Branch: 4 branches
BranchTrueFalseTotal
if ((v = h.fetch("max_age"))) c.max_age(v.as_number<uint64_t>()); 0 0 0
if ((v = h.fetch("max_age"))) c.max_age(v.as_number<uint64_t>()); 0 0 0
if ((v = h.fetch("max_age"))) c.max_age(v.as_number<uint64_t>()); 0 0 0
if ((v = h.fetch("max_age"))) c.max_age(v.as_number<uint64_t>()); 0 0 0
187 0 ▶ if ((v = h.fetch("secure"))) c.secure(v.is_true());
Branch: 3 branches
BranchTrueFalseTotal
if ((v = h.fetch("secure"))) c.secure(v.is_true()); 0 0 0
if ((v = h.fetch("secure"))) c.secure(v.is_true()); 0 0 0
if ((v = h.fetch("secure"))) c.secure(v.is_true()); 0 0 0
188 0 ▶ if ((v = h.fetch("http_only"))) c.http_only(v.is_true());
Branch: 3 branches
BranchTrueFalseTotal
if ((v = h.fetch("http_only"))) c.http_only(v.is_true()); 0 0 0
if ((v = h.fetch("http_only"))) c.http_only(v.is_true()); 0 0 0
if ((v = h.fetch("http_only"))) c.http_only(v.is_true()); 0 0 0
189 0 ▶ if ((v = h.fetch("same_site"))) c.same_site((Cookie::SameSite)v.as_number<int>());
Branch: 3 branches
BranchTrueFalseTotal
if ((v = h.fetch("same_site"))) c.same_site((Cookie::SameSite)v.as_number<int>()); 0 0 0
if ((v = h.fetch("same_site"))) c.same_site((Cookie::SameSite)v.as_number<int>()); 0 0 0
if ((v = h.fetch("same_site"))) c.same_site((Cookie::SameSite)v.as_number<int>()); 0 0 0
190 0 return c;
191 0 }
192  
193 0 Sv Typemap<Response::Cookie>::out (const Response::Cookie& c, const Sv& ) {
194 0 ▶ Hash h = Hash::create();
Branch: 1 branch
BranchTrueFalseTotal
Hash h = Hash::create(); 0 0 0
195 0 ▶ h["value"] = xs::out(c.value());
Branch: 3 branches
BranchTrueFalseTotal
h["value"] = xs::out(c.value()); 0 0 0
h["value"] = xs::out(c.value()); 0 0 0
h["value"] = xs::out(c.value()); 0 0 0
196 0 ▶ h["secure"] = xs::out(c.secure());
Branch: 3 branches
BranchTrueFalseTotal
h["secure"] = xs::out(c.secure()); 0 0 0
h["secure"] = xs::out(c.secure()); 0 0 0
h["secure"] = xs::out(c.secure()); 0 0 0
197 0 ▶ h["http_only"] = xs::out(c.http_only());
Branch: 3 branches
BranchTrueFalseTotal
h["http_only"] = xs::out(c.http_only()); 0 0 0
h["http_only"] = xs::out(c.http_only()); 0 0 0
h["http_only"] = xs::out(c.http_only()); 0 0 0
198 0 ▶ h["same_site"] = xs::out((int)c.same_site());
Branch: 3 branches
BranchTrueFalseTotal
h["same_site"] = xs::out((int)c.same_site()); 0 0 0
h["same_site"] = xs::out((int)c.same_site()); 0 0 0
h["same_site"] = xs::out((int)c.same_site()); 0 0 0
199  
200 0 ▶ if (c.domain()) { h["domain"] = xs::out(c.domain()); }
Branch: 4 branches
BranchTrueFalseTotal
if (c.domain()) { h["domain"] = xs::out(c.domain()); } 0 0 0
if (c.domain()) { h["domain"] = xs::out(c.domain()); } 0 0 0
if (c.domain()) { h["domain"] = xs::out(c.domain()); } 0 0 0
if (c.domain()) { h["domain"] = xs::out(c.domain()); } 0 0 0
201 0 ▶ if (c.path()) { h["path"] = xs::out(c.path()); }
Branch: 4 branches
BranchTrueFalseTotal
if (c.path()) { h["path"] = xs::out(c.path()); } 0 0 0
if (c.path()) { h["path"] = xs::out(c.path()); } 0 0 0
if (c.path()) { h["path"] = xs::out(c.path()); } 0 0 0
if (c.path()) { h["path"] = xs::out(c.path()); } 0 0 0
202 0 ▶ if (c.expires()) { h["expires"] = xs::out(c.expires()); }
Branch: 6 branches
BranchTrueFalseTotal
if (c.expires()) { h["expires"] = xs::out(c.expires()); } 0 0 0
if (c.expires()) { h["expires"] = xs::out(c.expires()); } 0 0 0
if (c.expires()) { h["expires"] = xs::out(c.expires()); } 0 0 0
if (c.expires()) { h["expires"] = xs::out(c.expires()); } 0 0 0
if (c.expires()) { h["expires"] = xs::out(c.expires()); } 0 0 0
if (c.expires()) { h["expires"] = xs::out(c.expires()); } 0 0 0
203 0 ▶ if (c.max_age()) { h["max_age"] = xs::out(c.max_age()); }
Branch: 4 branches
BranchTrueFalseTotal
if (c.max_age()) { h["max_age"] = xs::out(c.max_age()); } 0 0 0
if (c.max_age()) { h["max_age"] = xs::out(c.max_age()); } 0 0 0
if (c.max_age()) { h["max_age"] = xs::out(c.max_age()); } 0 0 0
if (c.max_age()) { h["max_age"] = xs::out(c.max_age()); } 0 0 0
204 0 ▶ return Ref::create(h);
Branch: 1 branch
BranchTrueFalseTotal
return Ref::create(h); 0 0 0
205 0 }
206  
207 0 Sv Typemap<CookieJar::Cookie>::out (const CookieJar::Cookie& c, const Sv&) {
208 0 ▶ Ref r = xs::out<Response::Cookie>(c);
Branch: 2 branches
BranchTrueFalseTotal
Ref r = xs::out<Response::Cookie>(c); 0 0 0
Ref r = xs::out<Response::Cookie>(c); 0 0 0
209 0 ▶ Hash h(r);
Branch: 1 branch
BranchTrueFalseTotal
Hash h(r); 0 0 0
210 0 ▶ h["name"] = xs::out(c.name());
Branch: 3 branches
BranchTrueFalseTotal
h["name"] = xs::out(c.name()); 0 0 0
h["name"] = xs::out(c.name()); 0 0 0
h["name"] = xs::out(c.name()); 0 0 0
211 0 ▶ h["host_only"] = c.host_only() ? Simple::yes : Simple::no;
Branch: 3 branches
BranchTrueFalseTotal
h["host_only"] = c.host_only() ? Simple::yes : Simple::no; 0 0 0
h["host_only"] = c.host_only() ? Simple::yes : Simple::no; 0 0 0
h["host_only"] = c.host_only() ? Simple::yes : Simple::no; 0 0 0
212 0 ▶ if (c.origin()) h["origin"] = xs::out(c.origin());
Branch: 4 branches
BranchTrueFalseTotal
if (c.origin()) h["origin"] = xs::out(c.origin()); 0 0 0
if (c.origin()) h["origin"] = xs::out(c.origin()); 0 0 0
if (c.origin()) h["origin"] = xs::out(c.origin()); 0 0 0
if (c.origin()) h["origin"] = xs::out(c.origin()); 0 0 0
213 0 return std::move(r);
214 0 }
215  
216 0 Sv Typemap<CookieJar::Cookies>::out(const CookieJar::Cookies& cookies, const Sv&) {
217 0 ▶ auto r = Array::create(cookies.size());
Branch: 1 branch
BranchTrueFalseTotal
auto r = Array::create(cookies.size()); 0 0 0
218 0 ▶ for (auto& coo: cookies) r.push(xs::out(coo));
Branch: 3 branches
BranchTrueFalseTotal
for (auto& coo: cookies) r.push(xs::out(coo)); 0 0 0
for (auto& coo: cookies) r.push(xs::out(coo)); 0 0 0
for (auto& coo: cookies) r.push(xs::out(coo)); 0 0 0
219 0 ▶ return Ref::create(r);
Branch: 1 branch
BranchTrueFalseTotal
return Ref::create(r); 0 0 0
220 0 }
221  
222 0 Sv Typemap<CookieJar::DomainCookies>::out(const DomainCookies& domain_cookies, const Sv&) {
223 0 ▶ Hash h = Hash::create();
Branch: 1 branch
BranchTrueFalseTotal
Hash h = Hash::create(); 0 0 0
224 0 ▶ for(auto& pair : domain_cookies) {
Branch: 1 branch
BranchTrueFalseTotal
for(auto& pair : domain_cookies) { 0 0 0
225 0 ▶ auto domain = pair.first.substr(1); // cut "." part
Branch: 1 branch
BranchTrueFalseTotal
auto domain = pair.first.substr(1); // cut "." part 0 0 0
226 0 ▶ h[domain] = xs::out(pair.second);
Branch: 3 branches
BranchTrueFalseTotal
h[domain] = xs::out(pair.second); 0 0 0
h[domain] = xs::out(pair.second); 0 0 0
h[domain] = xs::out(pair.second); 0 0 0
227 0 }
228 0 ▶ return Ref::create(h);
Branch: 1 branch
BranchTrueFalseTotal
return Ref::create(h); 0 0 0
229 0 }
230  
231 }
« blib/arch/Protocol/HTTP/ResponseParser.pm ↑ Summary src/xs/protocol/http.h »