Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
a4b2314b
Commit
a4b2314b
authored
Oct 21, 2018
by
Dennis Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initialize class members (-Weffc++ findings).
parent
308880d2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
21 deletions
+109
-21
include/pistache/client.h
include/pistache/client.h
+6
-0
include/pistache/http_header.h
include/pistache/http_header.h
+48
-17
include/pistache/mailbox.h
include/pistache/mailbox.h
+9
-1
include/pistache/mime.h
include/pistache/mime.h
+21
-0
include/pistache/reactor.h
include/pistache/reactor.h
+9
-0
src/client/client.cc
src/client/client.cc
+6
-2
src/common/http_defs.cc
src/common/http_defs.cc
+4
-0
src/common/http_header.cc
src/common/http_header.cc
+6
-1
No files found.
include/pistache/client.h
View file @
a4b2314b
...
@@ -138,6 +138,12 @@ private:
...
@@ -138,6 +138,12 @@ private:
class
ConnectionPool
{
class
ConnectionPool
{
public:
public:
ConnectionPool
()
:
connsLock
()
,
conns
()
,
maxConnectionsPerHost
()
{
}
void
init
(
size_t
maxConnsPerHost
);
void
init
(
size_t
maxConnsPerHost
);
std
::
shared_ptr
<
Connection
>
pickConnection
(
const
std
::
string
&
domain
);
std
::
shared_ptr
<
Connection
>
pickConnection
(
const
std
::
string
&
domain
);
...
...
include/pistache/http_header.h
View file @
a4b2314b
...
@@ -118,7 +118,9 @@ class Allow : public Header {
...
@@ -118,7 +118,9 @@ class Allow : public Header {
public:
public:
NAME
(
"Allow"
);
NAME
(
"Allow"
);
Allow
()
{
}
Allow
()
:
methods_
()
{
}
explicit
Allow
(
const
std
::
vector
<
Http
::
Method
>&
methods
)
explicit
Allow
(
const
std
::
vector
<
Http
::
Method
>&
methods
)
:
methods_
(
methods
)
:
methods_
(
methods
)
...
@@ -128,6 +130,7 @@ public:
...
@@ -128,6 +130,7 @@ public:
{
}
{
}
explicit
Allow
(
Http
::
Method
method
)
explicit
Allow
(
Http
::
Method
method
)
:
methods_
()
{
{
methods_
.
push_back
(
method
);
methods_
.
push_back
(
method
);
}
}
...
@@ -149,7 +152,9 @@ class Accept : public Header {
...
@@ -149,7 +152,9 @@ class Accept : public Header {
public:
public:
NAME
(
"Accept"
)
NAME
(
"Accept"
)
Accept
()
{
}
Accept
()
:
mediaRange_
()
{
}
void
parseRaw
(
const
char
*
str
,
size_t
len
);
void
parseRaw
(
const
char
*
str
,
size_t
len
);
void
write
(
std
::
ostream
&
os
)
const
;
void
write
(
std
::
ostream
&
os
)
const
;
...
@@ -164,7 +169,9 @@ class AccessControlAllowOrigin : public Header {
...
@@ -164,7 +169,9 @@ class AccessControlAllowOrigin : public Header {
public:
public:
NAME
(
"Access-Control-Allow-Origin"
)
NAME
(
"Access-Control-Allow-Origin"
)
AccessControlAllowOrigin
()
{
}
AccessControlAllowOrigin
()
:
uri_
()
{
}
explicit
AccessControlAllowOrigin
(
const
char
*
uri
)
explicit
AccessControlAllowOrigin
(
const
char
*
uri
)
:
uri_
(
uri
)
:
uri_
(
uri
)
...
@@ -190,7 +197,9 @@ class AccessControlAllowHeaders : public Header {
...
@@ -190,7 +197,9 @@ class AccessControlAllowHeaders : public Header {
public:
public:
NAME
(
"Access-Control-Allow-Headers"
)
NAME
(
"Access-Control-Allow-Headers"
)
AccessControlAllowHeaders
()
{
}
AccessControlAllowHeaders
()
:
val_
()
{
}
explicit
AccessControlAllowHeaders
(
const
char
*
val
)
explicit
AccessControlAllowHeaders
(
const
char
*
val
)
:
val_
(
val
)
:
val_
(
val
)
...
@@ -216,7 +225,10 @@ class CacheControl : public Header {
...
@@ -216,7 +225,10 @@ class CacheControl : public Header {
public:
public:
NAME
(
"Cache-Control"
)
NAME
(
"Cache-Control"
)
CacheControl
()
{
}
CacheControl
()
:
directives_
()
{
}
explicit
CacheControl
(
const
std
::
vector
<
Http
::
CacheDirective
>&
directives
)
explicit
CacheControl
(
const
std
::
vector
<
Http
::
CacheDirective
>&
directives
)
:
directives_
(
directives
)
:
directives_
(
directives
)
{
}
{
}
...
@@ -258,6 +270,10 @@ private:
...
@@ -258,6 +270,10 @@ private:
class
EncodingHeader
:
public
Header
{
class
EncodingHeader
:
public
Header
{
public:
public:
EncodingHeader
()
:
encoding_
()
{
}
void
parseRaw
(
const
char
*
str
,
size_t
len
);
void
parseRaw
(
const
char
*
str
,
size_t
len
);
void
write
(
std
::
ostream
&
os
)
const
;
void
write
(
std
::
ostream
&
os
)
const
;
...
@@ -325,10 +341,12 @@ class ContentType : public Header {
...
@@ -325,10 +341,12 @@ class ContentType : public Header {
public:
public:
NAME
(
"Content-Type"
)
NAME
(
"Content-Type"
)
ContentType
()
{
}
ContentType
()
:
mime_
()
{
}
explicit
ContentType
(
const
Mime
::
MediaType
&
mime
)
:
explicit
ContentType
(
const
Mime
::
MediaType
&
mime
)
mime_
(
mime
)
:
mime_
(
mime
)
{
}
{
}
void
parseRaw
(
const
char
*
str
,
size_t
len
);
void
parseRaw
(
const
char
*
str
,
size_t
len
);
...
@@ -346,10 +364,12 @@ class Date : public Header {
...
@@ -346,10 +364,12 @@ class Date : public Header {
public:
public:
NAME
(
"Date"
)
NAME
(
"Date"
)
Date
()
{
}
Date
()
:
fullDate_
()
{
}
explicit
Date
(
const
FullDate
&
date
)
:
explicit
Date
(
const
FullDate
&
date
)
fullDate_
(
date
)
:
fullDate_
(
date
)
{
}
{
}
void
parse
(
const
std
::
string
&
str
);
void
parse
(
const
std
::
string
&
str
);
...
@@ -365,10 +385,12 @@ class Expect : public Header {
...
@@ -365,10 +385,12 @@ class Expect : public Header {
public:
public:
NAME
(
"Expect"
)
NAME
(
"Expect"
)
Expect
()
{
}
Expect
()
:
expectation_
()
{
}
explicit
Expect
(
Http
::
Expectation
expectation
)
:
explicit
Expect
(
Http
::
Expectation
expectation
)
expectation_
(
expectation
)
:
expectation_
(
expectation
)
{
}
{
}
void
parseRaw
(
const
char
*
str
,
size_t
len
);
void
parseRaw
(
const
char
*
str
,
size_t
len
);
...
@@ -385,6 +407,8 @@ public:
...
@@ -385,6 +407,8 @@ public:
NAME
(
"Host"
);
NAME
(
"Host"
);
Host
()
Host
()
:
host_
()
,
port_
(
0
)
{
}
{
}
explicit
Host
(
const
std
::
string
&
host
);
explicit
Host
(
const
std
::
string
&
host
);
...
@@ -408,7 +432,9 @@ class Location : public Header {
...
@@ -408,7 +432,9 @@ class Location : public Header {
public:
public:
NAME
(
"Location"
)
NAME
(
"Location"
)
Location
()
{
}
Location
()
:
location_
()
{
}
explicit
Location
(
const
std
::
string
&
location
);
explicit
Location
(
const
std
::
string
&
location
);
...
@@ -425,7 +451,9 @@ class Server : public Header {
...
@@ -425,7 +451,9 @@ class Server : public Header {
public:
public:
NAME
(
"Server"
)
NAME
(
"Server"
)
Server
()
{
}
Server
()
:
tokens_
()
{
}
explicit
Server
(
const
std
::
vector
<
std
::
string
>&
tokens
);
explicit
Server
(
const
std
::
vector
<
std
::
string
>&
tokens
);
explicit
Server
(
const
std
::
string
&
token
);
explicit
Server
(
const
std
::
string
&
token
);
...
@@ -443,7 +471,10 @@ class UserAgent : public Header {
...
@@ -443,7 +471,10 @@ class UserAgent : public Header {
public:
public:
NAME
(
"User-Agent"
)
NAME
(
"User-Agent"
)
UserAgent
()
{
}
UserAgent
()
:
ua_
()
{
}
explicit
UserAgent
(
const
char
*
ua
)
explicit
UserAgent
(
const
char
*
ua
)
:
ua_
(
ua
)
:
ua_
(
ua
)
{
}
{
}
...
...
include/pistache/mailbox.h
View file @
a4b2314b
...
@@ -341,7 +341,11 @@ public:
...
@@ -341,7 +341,11 @@ public:
dequeueIndex
.
store
(
other
.
enqueueIndex
.
load
(),
std
::
memory_order_relaxed
);
dequeueIndex
.
store
(
other
.
enqueueIndex
.
load
(),
std
::
memory_order_relaxed
);
}
}
MPMCQueue
()
{
MPMCQueue
()
:
cells_
()
,
enqueueIndex
()
,
dequeueIndex
()
{
for
(
size_t
i
=
0
;
i
<
Size
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
Size
;
++
i
)
{
cells_
[
i
].
sequence
.
store
(
i
,
std
::
memory_order_relaxed
);
cells_
[
i
].
sequence
.
store
(
i
,
std
::
memory_order_relaxed
);
}
}
...
@@ -400,6 +404,10 @@ public:
...
@@ -400,6 +404,10 @@ public:
private:
private:
struct
Cell
{
struct
Cell
{
Cell
()
:
sequence
()
,
data
()
{
}
std
::
atomic
<
size_t
>
sequence
;
std
::
atomic
<
size_t
>
sequence
;
T
data
;
T
data
;
};
};
...
...
include/pistache/mime.h
View file @
a4b2314b
...
@@ -89,6 +89,7 @@ public:
...
@@ -89,6 +89,7 @@ public:
typedef
uint16_t
Type
;
typedef
uint16_t
Type
;
explicit
Q
(
Type
val
)
explicit
Q
(
Type
val
)
:
val_
()
{
{
if
(
val
>
100
)
{
if
(
val
>
100
)
{
throw
std
::
runtime_error
(
"Invalid quality value, must be in the [0; 100] range"
);
throw
std
::
runtime_error
(
"Invalid quality value, must be in the [0; 100] range"
);
...
@@ -123,12 +124,22 @@ public:
...
@@ -123,12 +124,22 @@ public:
:
top_
(
Type
::
None
)
:
top_
(
Type
::
None
)
,
sub_
(
Subtype
::
None
)
,
sub_
(
Subtype
::
None
)
,
suffix_
(
Suffix
::
None
)
,
suffix_
(
Suffix
::
None
)
,
raw_
()
,
rawSubIndex
()
,
rawSuffixIndex
()
,
params
()
,
q_
()
{
}
{
}
MediaType
(
std
::
string
raw
,
Parse
parse
=
DontParse
)
MediaType
(
std
::
string
raw
,
Parse
parse
=
DontParse
)
:
top_
(
Type
::
None
)
:
top_
(
Type
::
None
)
,
sub_
(
Subtype
::
None
)
,
sub_
(
Subtype
::
None
)
,
suffix_
(
Suffix
::
None
)
,
suffix_
(
Suffix
::
None
)
,
raw_
()
,
rawSubIndex
()
,
rawSuffixIndex
()
,
params
()
,
q_
()
{
{
if
(
parse
==
DoParse
)
{
if
(
parse
==
DoParse
)
{
parseRaw
(
raw
.
c_str
(),
raw
.
length
());
parseRaw
(
raw
.
c_str
(),
raw
.
length
());
...
@@ -142,12 +153,22 @@ public:
...
@@ -142,12 +153,22 @@ public:
:
top_
(
top
)
:
top_
(
top
)
,
sub_
(
sub
)
,
sub_
(
sub
)
,
suffix_
(
Suffix
::
None
)
,
suffix_
(
Suffix
::
None
)
,
raw_
()
,
rawSubIndex
()
,
rawSuffixIndex
()
,
params
()
,
q_
()
{
}
{
}
MediaType
(
Mime
::
Type
top
,
Mime
::
Subtype
sub
,
Mime
::
Suffix
suffix
)
MediaType
(
Mime
::
Type
top
,
Mime
::
Subtype
sub
,
Mime
::
Suffix
suffix
)
:
top_
(
top
)
:
top_
(
top
)
,
sub_
(
sub
)
,
sub_
(
sub
)
,
suffix_
(
suffix
)
,
suffix_
(
suffix
)
,
raw_
()
,
rawSubIndex
()
,
rawSuffixIndex
()
,
params
()
,
q_
()
{
}
{
}
...
...
include/pistache/reactor.h
View file @
a4b2314b
...
@@ -29,6 +29,7 @@ namespace Aio {
...
@@ -29,6 +29,7 @@ namespace Aio {
class
FdSet
{
class
FdSet
{
public:
public:
FdSet
(
std
::
vector
<
Polling
::
Event
>&&
events
)
FdSet
(
std
::
vector
<
Polling
::
Event
>&&
events
)
:
events_
()
{
{
events_
.
reserve
(
events
.
size
());
events_
.
reserve
(
events
.
size
());
for
(
auto
&&
event
:
events
)
{
for
(
auto
&&
event
:
events
)
{
...
@@ -163,11 +164,13 @@ private:
...
@@ -163,11 +164,13 @@ private:
class
ExecutionContext
{
class
ExecutionContext
{
public:
public:
virtual
~
ExecutionContext
()
{}
virtual
Reactor
::
Impl
*
makeImpl
(
Reactor
*
reactor
)
const
=
0
;
virtual
Reactor
::
Impl
*
makeImpl
(
Reactor
*
reactor
)
const
=
0
;
};
};
class
SyncContext
:
public
ExecutionContext
{
class
SyncContext
:
public
ExecutionContext
{
public:
public:
virtual
~
SyncContext
()
{}
Reactor
::
Impl
*
makeImpl
(
Reactor
*
reactor
)
const
override
;
Reactor
::
Impl
*
makeImpl
(
Reactor
*
reactor
)
const
override
;
};
};
...
@@ -177,6 +180,8 @@ public:
...
@@ -177,6 +180,8 @@ public:
:
threads_
(
threads
)
:
threads_
(
threads
)
{
}
{
}
virtual
~
AsyncContext
()
{}
Reactor
::
Impl
*
makeImpl
(
Reactor
*
reactor
)
const
override
;
Reactor
::
Impl
*
makeImpl
(
Reactor
*
reactor
)
const
override
;
static
AsyncContext
singleThreaded
();
static
AsyncContext
singleThreaded
();
...
@@ -200,6 +205,10 @@ public:
...
@@ -200,6 +205,10 @@ public:
struct
Context
{
struct
Context
{
friend
class
SyncImpl
;
friend
class
SyncImpl
;
Context
()
:
tid
()
{
}
std
::
thread
::
id
thread
()
const
{
return
tid
;
}
std
::
thread
::
id
thread
()
const
{
return
tid
;
}
private:
private:
...
...
src/client/client.cc
View file @
a4b2314b
...
@@ -758,9 +758,13 @@ Client::Options::maxConnectionsPerHost(int val) {
...
@@ -758,9 +758,13 @@ Client::Options::maxConnectionsPerHost(int val) {
Client
::
Client
()
Client
::
Client
()
:
reactor_
(
Aio
::
Reactor
::
create
())
:
reactor_
(
Aio
::
Reactor
::
create
())
,
pool
()
,
transport_
()
,
transportKey
()
,
ioIndex
(
0
)
,
ioIndex
(
0
)
{
,
queuesLock
()
}
,
requestsQueues
()
{
}
Client
::~
Client
()
{
Client
::~
Client
()
{
}
}
...
...
src/common/http_defs.cc
View file @
a4b2314b
...
@@ -41,11 +41,15 @@ namespace {
...
@@ -41,11 +41,15 @@ namespace {
}
// anonymous namespace
}
// anonymous namespace
CacheDirective
::
CacheDirective
(
Directive
directive
)
CacheDirective
::
CacheDirective
(
Directive
directive
)
:
directive_
()
,
data
()
{
{
init
(
directive
,
std
::
chrono
::
seconds
(
0
));
init
(
directive
,
std
::
chrono
::
seconds
(
0
));
}
}
CacheDirective
::
CacheDirective
(
Directive
directive
,
std
::
chrono
::
seconds
delta
)
CacheDirective
::
CacheDirective
(
Directive
directive
,
std
::
chrono
::
seconds
delta
)
:
directive_
()
,
data
()
{
{
init
(
directive
,
delta
);
init
(
directive
,
delta
);
}
}
...
...
src/common/http_header.cc
View file @
a4b2314b
...
@@ -331,7 +331,10 @@ Expect::write(std::ostream& os) const {
...
@@ -331,7 +331,10 @@ Expect::write(std::ostream& os) const {
}
}
}
}
Host
::
Host
(
const
std
::
string
&
data
)
{
Host
::
Host
(
const
std
::
string
&
data
)
:
host_
()
,
port_
(
0
)
{
parse
(
data
);
parse
(
data
);
}
}
...
@@ -474,11 +477,13 @@ Server::Server(const std::vector<std::string>& tokens)
...
@@ -474,11 +477,13 @@ Server::Server(const std::vector<std::string>& tokens)
{
}
{
}
Server
::
Server
(
const
std
::
string
&
token
)
Server
::
Server
(
const
std
::
string
&
token
)
:
tokens_
()
{
{
tokens_
.
push_back
(
token
);
tokens_
.
push_back
(
token
);
}
}
Server
::
Server
(
const
char
*
token
)
Server
::
Server
(
const
char
*
token
)
:
tokens_
()
{
{
tokens_
.
emplace_back
(
token
);
tokens_
.
emplace_back
(
token
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment