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
4147d67b
Commit
4147d67b
authored
Feb 02, 2019
by
knowledge4igor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add overload for out operator in Cookie
parent
a95c97af
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
4 deletions
+15
-4
include/pistache/cookie.h
include/pistache/cookie.h
+5
-0
src/common/cookie.cc
src/common/cookie.cc
+6
-0
src/common/http.cc
src/common/http.cc
+1
-1
tests/cookie_test.cc
tests/cookie_test.cc
+3
-3
No files found.
include/pistache/cookie.h
View file @
4147d67b
...
@@ -20,6 +20,8 @@ namespace Pistache {
...
@@ -20,6 +20,8 @@ namespace Pistache {
namespace
Http
{
namespace
Http
{
struct
Cookie
{
struct
Cookie
{
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Cookie
&
cookie
);
Cookie
(
std
::
string
name
,
std
::
string
value
);
Cookie
(
std
::
string
name
,
std
::
string
value
);
std
::
string
name
;
std
::
string
name
;
...
@@ -38,9 +40,12 @@ struct Cookie {
...
@@ -38,9 +40,12 @@ struct Cookie {
static
Cookie
fromRaw
(
const
char
*
str
,
size_t
len
);
static
Cookie
fromRaw
(
const
char
*
str
,
size_t
len
);
static
Cookie
fromString
(
const
std
::
string
&
str
);
static
Cookie
fromString
(
const
std
::
string
&
str
);
private:
void
write
(
std
::
ostream
&
os
)
const
;
void
write
(
std
::
ostream
&
os
)
const
;
};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Cookie
&
cookie
);
class
CookieJar
{
class
CookieJar
{
public:
public:
using
HashMapCookies
=
std
::
unordered_map
<
std
::
string
,
Cookie
>
;
// "value" -> Cookie
using
HashMapCookies
=
std
::
unordered_map
<
std
::
string
,
Cookie
>
;
// "value" -> Cookie
...
...
src/common/cookie.cc
View file @
4147d67b
...
@@ -207,6 +207,12 @@ Cookie::write(std::ostream& os) const {
...
@@ -207,6 +207,12 @@ Cookie::write(std::ostream& os) const {
}
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Cookie
&
cookie
)
{
cookie
.
write
(
os
);
return
os
;
}
CookieJar
::
CookieJar
()
CookieJar
::
CookieJar
()
:
cookies
()
:
cookies
()
{
}
{
}
...
...
src/common/http.cc
View file @
4147d67b
...
@@ -90,7 +90,7 @@ namespace {
...
@@ -90,7 +90,7 @@ namespace {
std
::
ostream
os
(
&
buf
);
std
::
ostream
os
(
&
buf
);
for
(
const
auto
&
cookie
:
cookies
)
{
for
(
const
auto
&
cookie
:
cookies
)
{
OUT
(
os
<<
"Set-Cookie: "
);
OUT
(
os
<<
"Set-Cookie: "
);
OUT
(
cookie
.
write
(
os
)
);
OUT
(
os
<<
cookie
);
OUT
(
os
<<
crlf
);
OUT
(
os
<<
crlf
);
}
}
...
...
tests/cookie_test.cc
View file @
4147d67b
...
@@ -97,7 +97,7 @@ TEST(cookie_test, write_test) {
...
@@ -97,7 +97,7 @@ TEST(cookie_test, write_test) {
c1
.
domain
=
Some
(
std
::
string
(
"example.com"
));
c1
.
domain
=
Some
(
std
::
string
(
"example.com"
));
std
::
ostringstream
oss
;
std
::
ostringstream
oss
;
c1
.
write
(
oss
)
;
oss
<<
c1
;
ASSERT_EQ
(
oss
.
str
(),
"lang=fr-FR; Path=/; Domain=example.com"
);
ASSERT_EQ
(
oss
.
str
(),
"lang=fr-FR; Path=/; Domain=example.com"
);
...
@@ -110,13 +110,13 @@ TEST(cookie_test, write_test) {
...
@@ -110,13 +110,13 @@ TEST(cookie_test, write_test) {
c2
.
expires
=
Some
(
FullDate
(
expires
));
c2
.
expires
=
Some
(
FullDate
(
expires
));
oss
.
str
(
""
);
oss
.
str
(
""
);
c2
.
write
(
oss
)
;
oss
<<
c2
;
Cookie
c3
(
"lang"
,
"en-US"
);
Cookie
c3
(
"lang"
,
"en-US"
);
c3
.
secure
=
true
;
c3
.
secure
=
true
;
c3
.
ext
.
insert
(
std
::
make_pair
(
"Scope"
,
"Private"
));
c3
.
ext
.
insert
(
std
::
make_pair
(
"Scope"
,
"Private"
));
oss
.
str
(
""
);
oss
.
str
(
""
);
c3
.
write
(
oss
)
;
oss
<<
c3
;
ASSERT_EQ
(
oss
.
str
(),
"lang=en-US; Secure; Scope=Private"
);
ASSERT_EQ
(
oss
.
str
(),
"lang=en-US; Secure; Scope=Private"
);
}
}
...
...
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