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
9ba1fce2
Commit
9ba1fce2
authored
Oct 08, 2019
by
Marcin Romanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adedd Authorization Header
parent
acc1c838
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
0 deletions
+46
-0
include/pistache/http_header.h
include/pistache/http_header.h
+21
-0
src/common/http_header.cc
src/common/http_header.cc
+13
-0
src/common/http_headers.cc
src/common/http_headers.cc
+1
-0
tests/headers_test.cc
tests/headers_test.cc
+11
-0
No files found.
include/pistache/http_header.h
View file @
9ba1fce2
...
...
@@ -393,6 +393,27 @@ private:
uint64_t
value_
;
};
class
Authorization
:
public
Header
{
public:
NAME
(
"Authorization"
);
Authorization
()
:
value_
(
"NONE"
)
{
}
explicit
Authorization
(
std
::
string
val
)
:
value_
(
val
)
{
}
void
parse
(
const
std
::
string
&
data
)
override
;
void
write
(
std
::
ostream
&
os
)
const
override
;
std
::
string
value
()
const
{
return
value_
;
}
private:
std
::
string
value_
;
};
class
ContentType
:
public
Header
{
public:
NAME
(
"Content-Type"
)
...
...
src/common/http_header.cc
View file @
9ba1fce2
...
...
@@ -304,6 +304,19 @@ ContentLength::write(std::ostream& os) const {
os
<<
value_
;
}
void
Authorization
::
parse
(
const
std
::
string
&
data
)
{
try
{
value_
=
data
;
}
catch
(
const
std
::
invalid_argument
&
e
)
{
}
}
void
Authorization
::
write
(
std
::
ostream
&
os
)
const
{
os
<<
value_
;
}
void
Date
::
parse
(
const
std
::
string
&
str
)
{
fullDate_
=
FullDate
::
fromString
(
str
);
...
...
src/common/http_headers.cc
View file @
9ba1fce2
...
...
@@ -27,6 +27,7 @@ RegisterHeader(ContentEncoding);
RegisterHeader
(
TransferEncoding
);
RegisterHeader
(
ContentLength
);
RegisterHeader
(
ContentType
);
RegisterHeader
(
Authorization
);
RegisterHeader
(
Date
);
RegisterHeader
(
Expect
);
RegisterHeader
(
Host
);
...
...
tests/headers_test.cc
View file @
9ba1fce2
...
...
@@ -247,6 +247,17 @@ TEST(headers_test, content_length)
ASSERT_TRUE
(
cl
.
value
()
==
3495U
);
}
TEST
(
headers_test
,
authorization_test
)
{
Pistache
::
Http
::
Header
::
Authorization
au
;
std
::
ostringstream
oss
;
au
.
parse
(
"Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE1NzA2MzA0MDcsImlhdCI6MTU3MDU0NDAwNywibmFtZSI6IkFkbWluIE5hbWUiLCJzYW1wbGUiOiJUZXN0In0.zLTAAnBftlqccsU-4mL69P4tQl3VhcglMg-d0131JxqX4xSZLlO5xMRrCPBgn_00OxKJ9CQdnpjpuzblNQd2-A"
);
au
.
write
(
oss
);
ASSERT_TRUE
(
"Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE1NzA2MzA0MDcsImlhdCI6MTU3MDU0NDAwNywibmFtZSI6IkFkbWluIE5hbWUiLCJzYW1wbGUiOiJUZXN0In0.zLTAAnBftlqccsU-4mL69P4tQl3VhcglMg-d0131JxqX4xSZLlO5xMRrCPBgn_00OxKJ9CQdnpjpuzblNQd2-A"
==
oss
.
str
());
ASSERT_TRUE
(
au
.
value
()
==
"Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXUyJ9.eyJleHAiOjE1NzA2MzA0MDcsImlhdCI6MTU3MDU0NDAwNywibmFtZSI6IkFkbWluIE5hbWUiLCJzYW1wbGUiOiJUZXN0In0.zLTAAnBftlqccsU-4mL69P4tQl3VhcglMg-d0131JxqX4xSZLlO5xMRrCPBgn_00OxKJ9CQdnpjpuzblNQd2-A"
);
}
TEST
(
headers_test
,
expect_test
)
{
Pistache
::
Http
::
Header
::
Expect
e
;
...
...
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