line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
namespace xs { namespace protocol { namespace http { |
10
|
|
|
|
|
|
|
using namespace panda::protocol::http; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
void fill (Request*, const Hash&); |
13
|
|
|
|
|
|
|
void fill (Response*, const Hash&); |
14
|
|
|
|
|
|
|
void fill_form(Request*, const Sv&); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
void set_headers (Message*, const Hash&); |
17
|
|
|
|
|
|
|
void set_method (Request*, const Sv&); |
18
|
|
|
|
|
|
|
void set_request_cookies (Request*, const Hash&); |
19
|
|
|
|
|
|
|
void set_response_cookies (Response*, const Hash&); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
template |
22
|
417
|
|
|
|
|
|
Simple strings_to_sv (const T& v) { |
23
|
417
|
|
|
|
|
|
size_t len = 0; |
24
|
75243
|
100
|
|
|
|
|
for (const auto& s : v) len += s.length(); |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
25
|
417
|
100
|
|
|
|
|
if (!len) return Simple::undef; |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
808
|
50
|
|
|
|
|
auto ret = Simple::create(len); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
28
|
391
|
|
|
|
|
|
char* dest = ret.get(); |
29
|
75211
|
100
|
|
|
|
|
for (const auto& s : v) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
30
|
74820
|
|
|
|
|
|
memcpy(dest, s.data(), s.length()); |
31
|
74820
|
|
|
|
|
|
dest += s.length(); |
32
|
|
|
|
|
|
|
} |
33
|
391
|
|
|
|
|
|
*dest = 0; |
34
|
391
|
|
|
|
|
|
ret.length(len); |
35
|
391
|
|
|
|
|
|
return ret; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
}}} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
namespace xs { |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
template <> |
42
|
|
|
|
|
|
|
struct Typemap : TypemapBase { |
43
|
|
|
|
|
|
|
using State = panda::protocol::http::State; |
44
|
|
|
|
|
|
|
static inline State in (SV* arg) { return (State)SvIV(arg); } |
45
|
|
|
|
|
|
|
static inline Sv out (State var, const Sv& = Sv()) { return Simple((int)var); } |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
template |
49
|
|
|
|
|
|
|
struct Typemap : TypemapObject {}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
template |
52
|
|
|
|
|
|
|
struct Typemap : Typemap { |
53
|
|
|
|
|
|
|
static panda::string_view package () { return "Protocol::HTTP::Request"; } |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
template |
57
|
|
|
|
|
|
|
struct Typemap> : Typemap { |
58
|
|
|
|
|
|
|
using Super = Typemap; |
59
|
|
|
|
|
|
|
static panda::iptr in (Sv arg) { |
60
|
|
|
|
|
|
|
if (arg.is_object_ref()) return Super::in(arg); |
61
|
|
|
|
|
|
|
else if (!arg.defined()) return {}; |
62
|
|
|
|
|
|
|
panda::iptr ret = make_backref(); |
63
|
|
|
|
|
|
|
xs::protocol::http::fill(ret.get(), arg); |
64
|
|
|
|
|
|
|
return ret; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
template |
69
|
|
|
|
|
|
|
struct Typemap : Typemap { |
70
|
0
|
|
|
|
|
|
static panda::string_view package () { return "Protocol::HTTP::Response"; } |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
template |
74
|
|
|
|
|
|
|
struct Typemap> : Typemap { |
75
|
|
|
|
|
|
|
using Super = Typemap; |
76
|
3
|
|
|
|
|
|
static panda::iptr in (Sv arg) { |
77
|
3
|
50
|
|
|
|
|
if (arg.is_object_ref()) return Super::in(arg); |
|
|
0
|
|
|
|
|
|
78
|
3
|
50
|
|
|
|
|
else if (!arg.defined()) return {}; |
79
|
6
|
50
|
|
|
|
|
panda::iptr ret = make_backref(); |
80
|
3
|
50
|
|
|
|
|
xs::protocol::http::fill(ret.get(), arg); |
|
|
50
|
|
|
|
|
|
81
|
3
|
|
|
|
|
|
return ret; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
template <> |
86
|
|
|
|
|
|
|
struct Typemap : TypemapBase { |
87
|
|
|
|
|
|
|
using Cookie = panda::protocol::http::Response::Cookie; |
88
|
|
|
|
|
|
|
static Cookie in (const Hash& arg); |
89
|
|
|
|
|
|
|
static Sv out (const Cookie&, const Sv& = {}); |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
template |
93
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
94
|
|
|
|
|
|
|
static std::string package () { return "Protocol::HTTP::RequestParser"; } |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
template |
98
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
99
|
|
|
|
|
|
|
static std::string package () { return "Protocol::HTTP::ResponseParser"; } |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
template |
103
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
104
|
|
|
|
|
|
|
static std::string package () { return "Protocol::HTTP::CookieJar"; } |
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
template <> |
108
|
|
|
|
|
|
|
struct Typemap : Typemap { |
109
|
|
|
|
|
|
|
using Cookie = panda::protocol::http::CookieJar::Cookie; |
110
|
|
|
|
|
|
|
static Sv out (const Cookie&, const Sv& = {}); |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
template <> |
114
|
|
|
|
|
|
|
struct Typemap : TypemapBase { |
115
|
|
|
|
|
|
|
using Cookies = panda::protocol::http::CookieJar::Cookies; |
116
|
|
|
|
|
|
|
static Sv out (const Cookies&, const Sv& = {}); |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
template <> |
120
|
|
|
|
|
|
|
struct Typemap : TypemapBase { |
121
|
|
|
|
|
|
|
using DomainCookies = panda::protocol::http::CookieJar::DomainCookies; |
122
|
|
|
|
|
|
|
static Sv out (const DomainCookies&, const Sv& = {}); |
123
|
|
|
|
|
|
|
}; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |