xs/Message.xsi

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 130 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 185 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/Error.xsi ↑ Summary xs/Request.xsi »
1 MODULE = Protocol::HTTP PACKAGE = Protocol::HTTP::Message
2 PROTOTYPES: DISABLE
3  
4 BOOT {
5 0 ▶ Stash stash(__PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
Stash stash(__PACKAGE__); 0 0 0
6 0 ▶ xs::exp::create_constants(stash, {
Branch: 4 branches
BranchTrueFalseTotal
xs::exp::create_constants(stash, { 0 0 0
xs::exp::create_constants(stash, { 0 0 0
xs::exp::create_constants(stash, { 0 0 0
xs::exp::create_constants(stash, { 0 0 0
7 {"STATE_HEADERS", (int)State::headers},
8 {"STATE_BODY", (int)State::body},
9 {"STATE_CHUNK", (int)State::chunk},
10 {"STATE_CHUNK_BODY", (int)State::chunk_body},
11 {"STATE_CHUNK_TRAILER", (int)State::chunk_trailer},
12 {"STATE_DONE", (int)State::done},
13 {"STATE_ERROR", (int)State::error}
14 });
15 0 ▶ xs::exp::autoexport(stash);
Branch: 2 branches
BranchTrueFalseTotal
xs::exp::autoexport(stash); 0 0 0
xs::exp::autoexport(stash); 0 0 0
16 0 }
17  
18 Hash Message::headers (Hash new_headers = Hash()) {
19 0 ▶ if (new_headers) {
Branch: 1 branch
BranchTrueFalseTotal
if (new_headers) { 0 0 0
20 0 ▶ set_headers(THIS, new_headers);
Branch: 1 branch
BranchTrueFalseTotal
set_headers(THIS, new_headers); 0 0 0
21 0 XSRETURN_UNDEF;
22 }
23  
24 0 ▶ RETVAL = Hash::create(THIS->headers.size());
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = Hash::create(THIS->headers.size()); 0 0 0
25 0 ▶ for (const auto& elem : THIS->headers.fields) {
Branch: 1 branch
BranchTrueFalseTotal
for (const auto& elem : THIS->headers.fields) { 0 0 0
26 0 auto len = elem.name.length();
27 0 auto key = (char*)alloca(sizeof(char)*len);
28 0 ▶ std::transform(elem.name.data(), elem.name.data() + len, key, ::tolower);
Branch: 1 branch
BranchTrueFalseTotal
std::transform(elem.name.data(), elem.name.data() + len, key, ::tolower); 0 0 0
29 0 ▶ RETVAL.store(string_view(key, len), xs::out(elem.value));
Branch: 2 branches
BranchTrueFalseTotal
RETVAL.store(string_view(key, len), xs::out(elem.value)); 0 0 0
RETVAL.store(string_view(key, len), xs::out(elem.value)); 0 0 0
30 }
31 }
32  
33 string Message::header (string_view name, SV* val = nullptr) {
34 0 ▶ if (val) {
Branch: 1 branch
BranchTrueFalseTotal
if (val) { 0 0 0
35 0 ▶ if (!sv_defined(val)) THIS->headers.remove(name);
Branch: 3 branches
BranchTrueFalseTotal
if (!sv_defined(val)) THIS->headers.remove(name); 0 0 0
if (!sv_defined(val)) THIS->headers.remove(name); 0 0 0
if (!sv_defined(val)) THIS->headers.remove(name); 0 0 0
36 0 ▶ else THIS->headers.set(string(name), xs::in<string>(val));
Branch: 3 branches
BranchTrueFalseTotal
else THIS->headers.set(string(name), xs::in<string>(val)); 0 0 0
else THIS->headers.set(string(name), xs::in<string>(val)); 0 0 0
else THIS->headers.set(string(name), xs::in<string>(val)); 0 0 0
37 0 XSRETURN_UNDEF;
38 }
39  
40 0 ▶ auto it = THIS->headers.find(name);
Branch: 1 branch
BranchTrueFalseTotal
auto it = THIS->headers.find(name); 0 0 0
41 0 ▶ if (it == THIS->headers.fields.end()) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (it == THIS->headers.fields.end()) XSRETURN_UNDEF; 0 0 0
42 0 ▶ RETVAL = it->value;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = it->value; 0 0 0
43 }
44  
45 void Message::multiheader (string_view name, ...) {
46 0 ▶ if (items > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 2) { 0 0 0
47 0 ▶ auto key = string(name);
Branch: 1 branch
BranchTrueFalseTotal
auto key = string(name); 0 0 0
48 0 ▶ for (auto i = 2; i < items; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (auto i = 2; i < items; ++i) { 0 0 0
49 0 auto val = ST(i);
50 0 ▶ if (sv_defined(val)) THIS->headers.add(key, xs::in<string>(val));
Branch: 4 branches
BranchTrueFalseTotal
if (sv_defined(val)) THIS->headers.add(key, xs::in<string>(val)); 0 0 0
if (sv_defined(val)) THIS->headers.add(key, xs::in<string>(val)); 0 0 0
if (sv_defined(val)) THIS->headers.add(key, xs::in<string>(val)); 0 0 0
if (sv_defined(val)) THIS->headers.add(key, xs::in<string>(val)); 0 0 0
51 }
52 0 XSRETURN_EMPTY;
53 0 }
54 0 ▶ for (auto& v : THIS->headers.get_multi(name)) {
Branch: 6 branches
BranchTrueFalseTotal
for (auto& v : THIS->headers.get_multi(name)) { 0 0 0
for (auto& v : THIS->headers.get_multi(name)) { 0 0 0
for (auto& v : THIS->headers.get_multi(name)) { 0 0 0
for (auto& v : THIS->headers.get_multi(name)) { 0 0 0
for (auto& v : THIS->headers.get_multi(name)) { 0 0 0
for (auto& v : THIS->headers.get_multi(name)) { 0 0 0
55 0 ▶ mXPUSHs(xs::out(v).detach());
Branch: 5 branches
BranchTrueFalseTotal
mXPUSHs(xs::out(v).detach()); 0 0 0
mXPUSHs(xs::out(v).detach()); 0 0 0
mXPUSHs(xs::out(v).detach()); 0 0 0
mXPUSHs(xs::out(v).detach()); 0 0 0
mXPUSHs(xs::out(v).detach()); 0 0 0
56 0 }
57 }
58  
59 size_t Message::headers_size () {
60 0 RETVAL = THIS->headers.size();
61 }
62  
63 Simple Message::body (SV* newval = nullptr) {
64 0 ▶ if (newval) {
Branch: 1 branch
BranchTrueFalseTotal
if (newval) { 0 0 0
65 0 ▶ THIS->body = xs::in<string>(newval);
Branch: 2 branches
BranchTrueFalseTotal
THIS->body = xs::in<string>(newval); 0 0 0
THIS->body = xs::in<string>(newval); 0 0 0
66 0 XSRETURN_UNDEF;
67 }
68 0 ▶ RETVAL = strings_to_sv(THIS->body.parts);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = strings_to_sv(THIS->body.parts); 0 0 0
69 }
70  
71 int Message::http_version (SV* newval = nullptr) {
72 0 ▶ if (newval) {
Branch: 1 branch
BranchTrueFalseTotal
if (newval) { 0 0 0
73 0 THIS->http_version = SvIV(newval);
74 0 XSRETURN_UNDEF;
75 }
76 0 ▶ RETVAL = THIS->http_version;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->http_version; 0 0 0
77 }
78  
79 bool Message::chunked (SV* newval = nullptr) {
80 0 ▶ if (newval) {
Branch: 1 branch
BranchTrueFalseTotal
if (newval) { 0 0 0
81 0 THIS->chunked = SvTRUE(newval);
82 0 XSRETURN_UNDEF;
83 }
84 0 ▶ RETVAL = THIS->chunked;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = THIS->chunked; 0 0 0
85 }
86  
87 Simple Message::make_chunk(string s) {
88 0 ▶ RETVAL = strings_to_sv(THIS->make_chunk(s));
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = strings_to_sv(THIS->make_chunk(s)); 0 0 0
RETVAL = strings_to_sv(THIS->make_chunk(s)); 0 0 0
89 }
90  
91 Simple Message::final_chunk(string s = {}) {
92 0 ▶ RETVAL = strings_to_sv(THIS->final_chunk(s));
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = strings_to_sv(THIS->final_chunk(s)); 0 0 0
RETVAL = strings_to_sv(THIS->final_chunk(s)); 0 0 0
93 }
94  
95 void Message::compression () {
96 0 ▶ if (GIMME_V == G_ARRAY) {
Branch: 1 branch
BranchTrueFalseTotal
if (GIMME_V == G_ARRAY) { 0 0 0
97 0 ▶ mPUSHs(Simple((int)THIS->compression.type).detach());
Branch: 2 branches
BranchTrueFalseTotal
mPUSHs(Simple((int)THIS->compression.type).detach()); 0 0 0
mPUSHs(Simple((int)THIS->compression.type).detach()); 0 0 0
98 0 ▶ mXPUSHs(Simple((int)THIS->compression.level).detach());
Branch: 3 branches
BranchTrueFalseTotal
mXPUSHs(Simple((int)THIS->compression.level).detach()); 0 0 0
mXPUSHs(Simple((int)THIS->compression.level).detach()); 0 0 0
mXPUSHs(Simple((int)THIS->compression.level).detach()); 0 0 0
99 0 XSRETURN(2);
100 }
101 else {
102 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
103 0 ▶ PUSHi((int)THIS->compression.type);
Branch: 1 branch
BranchTrueFalseTotal
PUSHi((int)THIS->compression.type); 0 0 0
104 }
105 }
106  
107 void Message::compress (int method, int level = (int)Compression::Level::min) {
108 0 ▶ if (level < (int)Compression::Level::min || level > (int)Compression::Level::max) throw "bad compression level";
Branch: 2 branches
BranchTrueFalseTotal
if (level < (int)Compression::Level::min || level > (int)Compression::Level::max) throw "bad compression level"; 0 0 0
if (level < (int)Compression::Level::min || level > (int)Compression::Level::max) throw "bad compression level"; 0 0 0
109 0 ▶ if (!is_valid_compression(method)) throw "bad compression";
Branch: 1 branch
BranchTrueFalseTotal
if (!is_valid_compression(method)) throw "bad compression"; 0 0 0
110
111 0 THIS->compress((Compression::Type)method, (Compression::Level)level);
112 }
113  
114 SV* CLONE_SKIP (...) {
115 0 XSRETURN_YES;
116 PERL_UNUSED_VAR(items);
117 }
« xs/Error.xsi ↑ Summary xs/Request.xsi »