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
26d82184
Commit
26d82184
authored
Dec 08, 2018
by
ciody
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add two more CORS headers
parent
5baa49ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
0 deletions
+94
-0
include/pistache/http_header.h
include/pistache/http_header.h
+56
-0
src/common/http_header.cc
src/common/http_header.cc
+20
-0
src/common/http_headers.cc
src/common/http_headers.cc
+2
-0
tests/headers_test.cc
tests/headers_test.cc
+16
-0
No files found.
include/pistache/http_header.h
View file @
26d82184
...
@@ -221,6 +221,62 @@ private:
...
@@ -221,6 +221,62 @@ private:
std
::
string
val_
;
std
::
string
val_
;
};
};
class
AccessControlExposeHeaders
:
public
Header
{
public:
NAME
(
"Access-Control-Expose-Headers"
)
AccessControlExposeHeaders
()
:
val_
()
{
}
explicit
AccessControlExposeHeaders
(
const
char
*
val
)
:
val_
(
val
)
{
}
explicit
AccessControlExposeHeaders
(
const
std
::
string
&
val
)
:
val_
(
val
)
{
}
void
parse
(
const
std
::
string
&
data
);
void
write
(
std
::
ostream
&
os
)
const
;
void
setUri
(
std
::
string
val
)
{
val_
=
std
::
move
(
val
);
}
std
::
string
val
()
const
{
return
val_
;
}
private:
std
::
string
val_
;
};
class
AccessControlAllowMethods
:
public
Header
{
public:
NAME
(
"Access-Control-Allow-Methods"
)
AccessControlAllowMethods
()
:
val_
()
{
}
explicit
AccessControlAllowMethods
(
const
char
*
val
)
:
val_
(
val
)
{
}
explicit
AccessControlAllowMethods
(
const
std
::
string
&
val
)
:
val_
(
val
)
{
}
void
parse
(
const
std
::
string
&
data
);
void
write
(
std
::
ostream
&
os
)
const
;
void
setUri
(
std
::
string
val
)
{
val_
=
std
::
move
(
val
);
}
std
::
string
val
()
const
{
return
val_
;
}
private:
std
::
string
val_
;
};
class
CacheControl
:
public
Header
{
class
CacheControl
:
public
Header
{
public:
public:
NAME
(
"Cache-Control"
)
NAME
(
"Cache-Control"
)
...
...
src/common/http_header.cc
View file @
26d82184
...
@@ -445,6 +445,26 @@ AccessControlAllowHeaders::write(std::ostream& os) const {
...
@@ -445,6 +445,26 @@ AccessControlAllowHeaders::write(std::ostream& os) const {
os
<<
val_
;
os
<<
val_
;
}
}
void
AccessControlExposeHeaders
::
parse
(
const
std
::
string
&
data
)
{
val_
=
data
;
}
void
AccessControlExposeHeaders
::
write
(
std
::
ostream
&
os
)
const
{
os
<<
val_
;
}
void
AccessControlAllowMethods
::
parse
(
const
std
::
string
&
data
)
{
val_
=
data
;
}
void
AccessControlAllowMethods
::
write
(
std
::
ostream
&
os
)
const
{
os
<<
val_
;
}
void
void
EncodingHeader
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
EncodingHeader
::
parseRaw
(
const
char
*
str
,
size_t
len
)
{
if
(
!
strncasecmp
(
str
,
"gzip"
,
len
))
{
if
(
!
strncasecmp
(
str
,
"gzip"
,
len
))
{
...
...
src/common/http_headers.cc
View file @
26d82184
...
@@ -17,6 +17,8 @@ namespace Header {
...
@@ -17,6 +17,8 @@ namespace Header {
RegisterHeader
(
Accept
);
RegisterHeader
(
Accept
);
RegisterHeader
(
AccessControlAllowOrigin
);
RegisterHeader
(
AccessControlAllowOrigin
);
RegisterHeader
(
AccessControlAllowHeaders
);
RegisterHeader
(
AccessControlAllowHeaders
);
RegisterHeader
(
AccessControlExposeHeaders
);
RegisterHeader
(
AccessControlAllowMethods
);
RegisterHeader
(
Allow
);
RegisterHeader
(
Allow
);
RegisterHeader
(
CacheControl
);
RegisterHeader
(
CacheControl
);
RegisterHeader
(
Connection
);
RegisterHeader
(
Connection
);
...
...
tests/headers_test.cc
View file @
26d82184
...
@@ -286,3 +286,19 @@ TEST(headers_test, access_control_allow_headers_test)
...
@@ -286,3 +286,19 @@ TEST(headers_test, access_control_allow_headers_test)
allowHeaders
.
parse
(
"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
);
allowHeaders
.
parse
(
"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
);
ASSERT_EQ
(
allowHeaders
.
val
(),
"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
);
ASSERT_EQ
(
allowHeaders
.
val
(),
"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
);
}
}
TEST
(
headers_test
,
access_control_expose_headers_test
)
{
Header
::
AccessControlExposeHeaders
exposeHeaders
;
exposeHeaders
.
parse
(
"Accept, Location"
);
ASSERT_EQ
(
exposeHeaders
.
val
(),
"Accept, Location"
);
}
TEST
(
headers_test
,
access_control_allow_methods_test
)
{
Header
::
AccessControlAllowMethods
allowMethods
;
allowMethods
.
parse
(
"GET, POST, DELETE"
);
ASSERT_EQ
(
allowMethods
.
val
(),
"GET, POST, DELETE"
);
}
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