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
54a37315
Commit
54a37315
authored
Jul 09, 2017
by
Daniel Moraes
Committed by
octal
Jul 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for case insensitive headers.
parent
11c248e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
include/pistache/http_headers.h
include/pistache/http_headers.h
+23
-1
src/common/http_headers.cc
src/common/http_headers.cc
+12
-1
No files found.
include/pistache/http_headers.h
View file @
54a37315
...
...
@@ -6,6 +6,8 @@
#pragma once
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <memory>
...
...
@@ -16,6 +18,21 @@ namespace Pistache {
namespace
Http
{
namespace
Header
{
std
::
string
toLowercase
(
std
::
string
str
);
struct
LowercaseHash
{
size_t
operator
()(
const
std
::
string
&
key
)
const
{
return
std
::
hash
<
std
::
string
>
{}(
toLowercase
(
key
));
}
};
struct
LowercaseEqual
{
bool
operator
()(
const
std
::
string
&
left
,
const
std
::
string
&
right
)
const
{
return
toLowercase
(
left
)
==
toLowercase
(
right
);
}
};
class
Collection
{
public:
...
...
@@ -94,7 +111,12 @@ public:
private:
std
::
pair
<
bool
,
std
::
shared_ptr
<
Header
>>
getImpl
(
const
std
::
string
&
name
)
const
;
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
Header
>>
headers
;
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
Header
>
,
LowercaseHash
,
LowercaseEqual
>
headers
;
std
::
unordered_map
<
std
::
string
,
Raw
>
rawHeaders
;
};
...
...
src/common/http_headers.cc
View file @
54a37315
...
...
@@ -16,7 +16,12 @@ namespace Http {
namespace
Header
{
namespace
{
std
::
unordered_map
<
std
::
string
,
Registry
::
RegistryFunc
>
registry
;
std
::
unordered_map
<
std
::
string
,
Registry
::
RegistryFunc
,
LowercaseHash
,
LowercaseEqual
>
registry
;
}
RegisterHeader
(
Accept
);
...
...
@@ -35,6 +40,12 @@ RegisterHeader(Location);
RegisterHeader
(
Server
);
RegisterHeader
(
UserAgent
);
std
::
string
toLowercase
(
std
::
string
str
)
{
std
::
transform
(
str
.
begin
(),
str
.
end
(),
str
.
begin
(),
::
tolower
);
return
str
;
}
void
Registry
::
registerHeader
(
std
::
string
name
,
Registry
::
RegistryFunc
func
)
{
...
...
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