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
43e1b4d5
Commit
43e1b4d5
authored
Aug 15, 2018
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Whitespace
parent
6b8cdfa3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
32 deletions
+32
-32
src/common/cookie.cc
src/common/cookie.cc
+26
-26
src/common/http.cc
src/common/http.cc
+1
-1
tests/cookie_test.cc
tests/cookie_test.cc
+5
-5
No files found.
src/common/cookie.cc
View file @
43e1b4d5
...
@@ -212,32 +212,32 @@ CookieJar::add(const Cookie& cookie) {
...
@@ -212,32 +212,32 @@ CookieJar::add(const Cookie& cookie) {
void
void
CookieJar
::
addFromRaw
(
const
char
*
str
,
size_t
len
)
{
CookieJar
::
addFromRaw
(
const
char
*
str
,
size_t
len
)
{
RawStreamBuf
<>
buf
(
const_cast
<
char
*>
(
str
),
len
);
RawStreamBuf
<>
buf
(
const_cast
<
char
*>
(
str
),
len
);
StreamCursor
cursor
(
&
buf
);
StreamCursor
cursor
(
&
buf
);
while
(
!
cursor
.
eof
())
{
while
(
!
cursor
.
eof
())
{
StreamCursor
::
Token
nameToken
(
cursor
);
StreamCursor
::
Token
nameToken
(
cursor
);
if
(
!
match_until
(
'='
,
cursor
))
if
(
!
match_until
(
'='
,
cursor
))
throw
std
::
runtime_error
(
"Invalid cookie, missing value"
);
throw
std
::
runtime_error
(
"Invalid cookie, missing value"
);
auto
name
=
nameToken
.
text
();
auto
name
=
nameToken
.
text
();
if
(
!
cursor
.
advance
(
1
))
if
(
!
cursor
.
advance
(
1
))
throw
std
::
runtime_error
(
"Invalid cookie, missing value"
);
throw
std
::
runtime_error
(
"Invalid cookie, missing value"
);
StreamCursor
::
Token
valueToken
(
cursor
);
StreamCursor
::
Token
valueToken
(
cursor
);
match_until
(
';'
,
cursor
);
match_until
(
';'
,
cursor
);
auto
value
=
valueToken
.
text
();
auto
value
=
valueToken
.
text
();
Cookie
cookie
(
std
::
move
(
name
),
std
::
move
(
value
));
Cookie
cookie
(
std
::
move
(
name
),
std
::
move
(
value
));
add
(
cookie
);
add
(
cookie
);
cursor
.
advance
(
1
);
cursor
.
advance
(
1
);
skip_whitespaces
(
cursor
);
skip_whitespaces
(
cursor
);
}
}
}
}
Cookie
Cookie
CookieJar
::
get
(
const
std
::
string
&
name
)
const
{
CookieJar
::
get
(
const
std
::
string
&
name
)
const
{
...
...
src/common/http.cc
View file @
43e1b4d5
...
@@ -294,7 +294,7 @@ namespace Private {
...
@@ -294,7 +294,7 @@ namespace Private {
}
}
if
(
name
==
"Cookie"
)
{
if
(
name
==
"Cookie"
)
{
message
->
cookies_
.
addFromRaw
(
cursor
.
offset
(
start
),
cursor
.
diff
(
start
));
message
->
cookies_
.
addFromRaw
(
cursor
.
offset
(
start
),
cursor
.
diff
(
start
));
}
}
else
if
(
Header
::
Registry
::
isRegistered
(
name
))
{
else
if
(
Header
::
Registry
::
isRegistered
(
name
))
{
...
...
tests/cookie_test.cc
View file @
43e1b4d5
...
@@ -137,14 +137,14 @@ void addCookies(const char* str, std::function<void (const CookieJar&)> testFunc
...
@@ -137,14 +137,14 @@ void addCookies(const char* str, std::function<void (const CookieJar&)> testFunc
TEST
(
cookie_test
,
cookiejar_test
)
{
TEST
(
cookie_test
,
cookiejar_test
)
{
addCookies
(
"key1=value1"
,
[](
const
CookieJar
&
jar
)
{
addCookies
(
"key1=value1"
,
[](
const
CookieJar
&
jar
)
{
ASSERT_EQ
(
jar
.
get
(
"key1"
).
value
,
"value1"
);
ASSERT_EQ
(
jar
.
get
(
"key1"
).
value
,
"value1"
);
});
});
addCookies
(
"key2=value2; key3=value3"
,
[](
const
CookieJar
&
jar
)
{
addCookies
(
"key2=value2; key3=value3"
,
[](
const
CookieJar
&
jar
)
{
ASSERT_EQ
(
jar
.
get
(
"key2"
).
value
,
"value2"
);
ASSERT_EQ
(
jar
.
get
(
"key2"
).
value
,
"value2"
);
ASSERT_EQ
(
jar
.
get
(
"key3"
).
value
,
"value3"
);
ASSERT_EQ
(
jar
.
get
(
"key3"
).
value
,
"value3"
);
});
});
CookieJar
jar
;
CookieJar
jar
;
ASSERT_THROW
(
jar
.
addFromRaw
(
"key4"
,
strlen
(
"key4"
)),
std
::
runtime_error
);
ASSERT_THROW
(
jar
.
addFromRaw
(
"key4"
,
strlen
(
"key4"
)),
std
::
runtime_error
);
}
}
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