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
6da6e356
Commit
6da6e356
authored
Mar 10, 2019
by
Arthur de Araújo Farias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving coverage for src/common/http_header.cc
parent
c2067dec
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
339 additions
and
81 deletions
+339
-81
.gitignore
.gitignore
+3
-1
libpistache-github.code-workspace
libpistache-github.code-workspace
+11
-0
src/common/http_header.cc
src/common/http_header.cc
+27
-24
tests/headers_test.cc
tests/headers_test.cc
+298
-56
No files found.
.gitignore
View file @
6da6e356
...
@@ -33,4 +33,6 @@ build
...
@@ -33,4 +33,6 @@ build
# Ignoring IDE files
# Ignoring IDE files
.vscode
.vscode
.idea
.idea
\ No newline at end of file
libpistache-github.code-workspace
libpistache-github.code-workspace
0 → 100644
View file @
6da6e356
{
"folders": [
{
"path": "."
}
],
"settings": {
"coverage-gutters.showLineCoverage": true,
"coverage-gutters.coverageReportFileName": "build/index.html"
}
}
\ No newline at end of file
src/common/http_header.cc
View file @
6da6e356
...
@@ -19,6 +19,22 @@ namespace Pistache {
...
@@ -19,6 +19,22 @@ namespace Pistache {
namespace
Http
{
namespace
Http
{
namespace
Header
{
namespace
Header
{
void
Header
::
parse
(
const
std
::
string
&
str
)
{
parseRaw
(
str
.
c_str
(),
str
.
length
());
}
void
Header
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
parse
(
std
::
string
(
str
,
len
));
}
void
Allow
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
UNUSED
(
str
)
UNUSED
(
len
)
}
const
char
*
encodingString
(
Encoding
encoding
)
{
const
char
*
encodingString
(
Encoding
encoding
)
{
switch
(
encoding
)
{
switch
(
encoding
)
{
case
Encoding
:
:
Gzip
:
case
Encoding
:
:
Gzip
:
...
@@ -32,26 +48,9 @@ const char* encodingString(Encoding encoding) {
...
@@ -32,26 +48,9 @@ const char* encodingString(Encoding encoding) {
case
Encoding
:
:
Chunked
:
case
Encoding
:
:
Chunked
:
return
"chunked"
;
return
"chunked"
;
case
Encoding
:
:
Unknown
:
case
Encoding
:
:
Unknown
:
default:
return
"unknown"
;
return
"unknown"
;
}
}
unreachable
();
}
void
Header
::
parse
(
const
std
::
string
&
data
)
{
parseRaw
(
data
.
c_str
(),
data
.
size
());
}
void
Header
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
parse
(
std
::
string
(
str
,
len
));
}
void
Allow
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
UNUSED
(
str
)
UNUSED
(
len
)
}
}
void
void
...
@@ -204,7 +203,6 @@ CacheControl::write(std::ostream& os) const {
...
@@ -204,7 +203,6 @@ CacheControl::write(std::ostream& os) const {
case
CacheDirective
:
:
SMaxAge
:
case
CacheDirective
:
:
SMaxAge
:
return
"s-maxage"
;
return
"s-maxage"
;
case
CacheDirective
:
:
Ext
:
case
CacheDirective
:
:
Ext
:
return
""
;
default:
default:
return
""
;
return
""
;
}
}
...
@@ -316,7 +314,7 @@ Date::write(std::ostream& os) const {
...
@@ -316,7 +314,7 @@ Date::write(std::ostream& os) const {
void
void
Expect
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
Expect
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
if
(
memcmp
(
str
,
"100-continue"
,
len
)
)
{
if
(
std
::
strcmp
(
str
,
"100-continue"
)
==
0
)
{
expectation_
=
Expectation
::
Continue
;
expectation_
=
Expectation
::
Continue
;
}
else
{
}
else
{
expectation_
=
Expectation
::
Ext
;
expectation_
=
Expectation
::
Ext
;
...
@@ -508,16 +506,21 @@ Server::Server(const char* token)
...
@@ -508,16 +506,21 @@ Server::Server(const char* token)
}
}
void
void
Server
::
parse
(
const
std
::
string
&
data
)
Server
::
parse
(
const
std
::
string
&
token
)
{
{
UNUSED
(
data
)
tokens_
.
push_back
(
token
);
}
}
void
void
Server
::
write
(
std
::
ostream
&
os
)
const
Server
::
write
(
std
::
ostream
&
os
)
const
{
{
std
::
copy
(
std
::
begin
(
tokens_
),
std
::
end
(
tokens_
),
for
(
int
i
=
0
;
i
<
tokens_
.
size
();
i
++
)
{
std
::
ostream_iterator
<
std
::
string
>
(
os
,
" "
));
auto
&
token
=
tokens_
[
i
];
os
<<
token
;
if
(
i
<
tokens_
.
size
()
-
1
)
{
os
<<
" "
;
}
}
}
}
void
void
...
...
tests/headers_test.cc
View file @
6da6e356
This diff is collapsed.
Click to expand it.
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