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
b1fd9c8f
Unverified
Commit
b1fd9c8f
authored
Oct 07, 2018
by
hasankandemir1993
Committed by
GitHub
Oct 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update cookie.h
parent
61af27cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
+36
-9
include/pistache/cookie.h
include/pistache/cookie.h
+36
-9
No files found.
include/pistache/cookie.h
View file @
b1fd9c8f
...
...
@@ -10,6 +10,8 @@
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <pistache/optional.h>
#include <pistache/http_defs.h>
...
...
@@ -41,25 +43,46 @@ struct Cookie {
class
CookieJar
{
public:
using
Storage
=
std
::
unordered_map
<
std
::
string
,
Cookie
>
;
typedef
std
::
unordered_map
<
std
::
string
,
Cookie
>
HashMapCookies
;
// "value" -> Cookie
typedef
std
::
unordered_map
<
std
::
string
,
HashMapCookies
>
Storage
;
// "name" -> Hashmap("value" -> Cookie)
struct
iterator
:
std
::
iterator
<
std
::
bidirectional_iterator_tag
,
Cookie
>
{
iterator
(
const
Storage
::
const_iterator
&
_iterator
)
:
it_
(
_iterator
)
{
}
{
}
iterator
(
const
Storage
::
const_iterator
&
_iterator
,
const
Storage
::
const_iterator
&
end
)
:
it_
(
_iterator
),
end_
(
end
)
{
if
(
it_
!=
end_
)
{
it_2
=
it_
->
second
.
begin
();
}
}
Cookie
operator
*
()
const
{
return
it_
->
second
;
return
it_
2
->
second
;
// return it_
->second;
}
iterator
operator
++
()
{
++
it_
;
return
iterator
(
it_
);
++
it_2
;
if
(
it_2
==
it_
->
second
.
end
())
{
++
it_
;
if
(
it_
!=
end_
)
it_2
=
it_
->
second
.
begin
();
}
return
iterator
(
it_
,
end_
);
}
iterator
operator
++
(
int
)
{
iterator
ret
(
it_
);
++
it_
;
iterator
ret
(
it_
,
end_
);
++
it_2
;
if
(
it_2
==
it_
->
second
.
end
())
{
++
it_
;
if
(
it_
!=
end_
)
// this check is important
it_2
=
it_
->
second
.
begin
();
}
return
ret
;
}
...
...
@@ -73,18 +96,22 @@ public:
private:
Storage
::
const_iterator
it_
;
HashMapCookies
::
const_iterator
it_2
;
Storage
::
const_iterator
end_
;
// we need to know where main hashmap ends.
};
CookieJar
();
void
add
(
const
Cookie
&
cookie
);
void
removeCookie
(
const
std
::
string
&
name
);
// ADDED LATER
void
addFromRaw
(
const
char
*
str
,
size_t
len
);
Cookie
get
(
const
std
::
string
&
name
)
const
;
bool
has
(
const
std
::
string
&
name
)
const
;
iterator
begin
()
const
{
return
iterator
(
cookies
.
begin
());
return
iterator
(
cookies
.
begin
()
,
cookies
.
end
()
);
}
iterator
end
()
const
{
...
...
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