Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
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
nghttp2
Commits
e457c9a4
Commit
e457c9a4
authored
Feb 22, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Add util::strieq_l
parent
997f9233
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
24 deletions
+48
-24
src/HttpServer.cc
src/HttpServer.cc
+1
-1
src/nghttp.cc
src/nghttp.cc
+3
-3
src/shrpx_config.cc
src/shrpx_config.cc
+11
-11
src/shrpx_http2_downstream_connection.cc
src/shrpx_http2_downstream_connection.cc
+1
-1
src/util.cc
src/util.cc
+0
-7
src/util.h
src/util.h
+20
-1
src/util_test.cc
src/util_test.cc
+12
-0
No files found.
src/HttpServer.cc
View file @
e457c9a4
...
...
@@ -1087,7 +1087,7 @@ int hd_on_frame_recv_callback(nghttp2_session *session,
auto
expect100
=
http2
::
get_header
(
stream
->
hdidx
,
http2
::
HD_EXPECT
,
stream
->
headers
);
if
(
expect100
&&
util
::
strieq
(
"100-continue"
,
expect100
->
value
.
c_str
()
))
{
if
(
expect100
&&
util
::
strieq
_l
(
"100-continue"
,
expect100
->
value
))
{
hd
->
submit_non_final_response
(
"100"
,
frame
->
hd
.
stream_id
);
}
...
...
src/nghttp.cc
View file @
e457c9a4
...
...
@@ -1596,8 +1596,8 @@ void check_response_header(nghttp2_session *session, Request *req) {
for
(
auto
&
nv
:
req
->
res_nva
)
{
if
(
"content-encoding"
==
nv
.
name
)
{
gzip
=
util
::
strieq
(
"gzip"
,
nv
.
value
)
||
util
::
strieq
(
"deflate"
,
nv
.
value
);
gzip
=
util
::
strieq_l
(
"gzip"
,
nv
.
value
)
||
util
::
strieq_l
(
"deflate"
,
nv
.
value
);
continue
;
}
}
...
...
@@ -2532,7 +2532,7 @@ int main(int argc, char **argv) {
}
// To test "never index" repr, don't index authorization header
// field unconditionally.
auto
no_index
=
util
::
strieq
(
"authorization"
,
header
);
auto
no_index
=
util
::
strieq
_l
(
"authorization"
,
header
);
config
.
headers
.
emplace_back
(
header
,
value
,
no_index
);
util
::
inp_strlower
(
config
.
headers
.
back
().
name
);
break
;
...
...
src/shrpx_config.cc
View file @
e457c9a4
...
...
@@ -442,31 +442,31 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
const
char
*
value
=
nullptr
;
size_t
valuelen
=
0
;
if
(
util
::
strieq
(
"$remote_addr"
,
var_start
,
varlen
))
{
if
(
util
::
strieq
_l
(
"$remote_addr"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_REMOTE_ADDR
;
}
else
if
(
util
::
strieq
(
"$time_local"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$time_local"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_TIME_LOCAL
;
}
else
if
(
util
::
strieq
(
"$time_iso8601"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$time_iso8601"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_TIME_ISO8601
;
}
else
if
(
util
::
strieq
(
"$request"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$request"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_REQUEST
;
}
else
if
(
util
::
strieq
(
"$status"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$status"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_STATUS
;
}
else
if
(
util
::
strieq
(
"$body_bytes_sent"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$body_bytes_sent"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_BODY_BYTES_SENT
;
}
else
if
(
util
::
istartsWith
(
var_start
,
varlen
,
"$http_"
))
{
type
=
SHRPX_LOGF_HTTP
;
value
=
var_start
+
sizeof
(
"$http_"
)
-
1
;
valuelen
=
varlen
-
(
sizeof
(
"$http_"
)
-
1
);
}
else
if
(
util
::
strieq
(
"$remote_port"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$remote_port"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_REMOTE_PORT
;
}
else
if
(
util
::
strieq
(
"$server_port"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$server_port"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_SERVER_PORT
;
}
else
if
(
util
::
strieq
(
"$request_time"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$request_time"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_REQUEST_TIME
;
}
else
if
(
util
::
strieq
(
"$pid"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$pid"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_PID
;
}
else
if
(
util
::
strieq
(
"$alpn"
,
var_start
,
varlen
))
{
}
else
if
(
util
::
strieq
_l
(
"$alpn"
,
var_start
,
varlen
))
{
type
=
SHRPX_LOGF_ALPN
;
}
else
{
LOG
(
WARN
)
<<
"Unrecognized log format variable: "
...
...
src/shrpx_http2_downstream_connection.cc
View file @
e457c9a4
...
...
@@ -383,7 +383,7 @@ int Http2DownstreamConnection::push_request_headers() {
auto
transfer_encoding
=
downstream_
->
get_request_header
(
http2
::
HD_TRANSFER_ENCODING
);
if
(
transfer_encoding
&&
util
::
strieq
((
*
transfer_encoding
).
value
.
c_str
(),
"chunked"
))
{
util
::
strieq
_l
(
"chunked"
,
(
*
transfer_encoding
).
value
))
{
chunked_encoding
=
true
;
}
...
...
src/util.cc
View file @
e457c9a4
...
...
@@ -381,13 +381,6 @@ bool istartsWith(const char *a, const char *b) {
return
!*
b
;
}
bool
strieq
(
const
std
::
string
&
a
,
const
std
::
string
&
b
)
{
if
(
a
.
size
()
!=
b
.
size
())
{
return
false
;
}
return
std
::
equal
(
std
::
begin
(
a
),
std
::
end
(
a
),
std
::
begin
(
b
),
CaseCmp
());
}
bool
strieq
(
const
char
*
a
,
const
char
*
b
)
{
if
(
!
a
||
!
b
)
{
return
false
;
...
...
src/util.h
View file @
e457c9a4
...
...
@@ -301,10 +301,29 @@ template <typename InputIt> bool strieq(const char *a, InputIt b, size_t bn) {
return
!*
a
&&
b
==
blast
;
}
bool
strieq
(
const
std
::
string
&
a
,
const
std
::
string
&
b
);
template
<
typename
InputIt1
,
typename
InputIt2
>
bool
strieq
(
InputIt1
a
,
size_t
alen
,
InputIt2
b
,
size_t
blen
)
{
if
(
alen
!=
blen
)
{
return
false
;
}
return
std
::
equal
(
a
,
a
+
alen
,
b
,
CaseCmp
());
}
inline
bool
strieq
(
const
std
::
string
&
a
,
const
std
::
string
&
b
)
{
return
strieq
(
std
::
begin
(
a
),
a
.
size
(),
std
::
begin
(
b
),
b
.
size
());
}
bool
strieq
(
const
char
*
a
,
const
char
*
b
);
template
<
typename
InputIt
,
size_t
N
>
bool
strieq_l
(
const
char
(
&
a
)[
N
],
InputIt
b
,
size_t
blen
)
{
return
strieq
(
a
,
N
-
1
,
b
,
blen
);
}
template
<
size_t
N
>
bool
strieq_l
(
const
char
(
&
a
)[
N
],
const
std
::
string
&
b
)
{
return
strieq
(
a
,
N
-
1
,
std
::
begin
(
b
),
b
.
size
());
}
template
<
typename
InputIt
>
bool
streq
(
const
char
*
a
,
InputIt
b
,
size_t
bn
)
{
if
(
!
a
)
{
return
false
;
...
...
src/util_test.cc
View file @
e457c9a4
...
...
@@ -84,6 +84,18 @@ void test_util_strieq(void) {
CU_ASSERT
(
util
::
strieq
(
""
,
""
));
CU_ASSERT
(
!
util
::
strieq
(
"alpha"
,
"AlPhA "
));
CU_ASSERT
(
!
util
::
strieq
(
""
,
"AlPhA "
));
CU_ASSERT
(
util
::
strieq_l
(
"alpha"
,
"alpha"
,
5
));
CU_ASSERT
(
util
::
strieq_l
(
"alpha"
,
"AlPhA"
,
5
));
CU_ASSERT
(
util
::
strieq_l
(
""
,
static_cast
<
const
char
*>
(
nullptr
),
0
));
CU_ASSERT
(
!
util
::
strieq_l
(
"alpha"
,
"AlPhA "
,
6
));
CU_ASSERT
(
!
util
::
strieq_l
(
""
,
"AlPhA "
,
6
));
CU_ASSERT
(
util
::
strieq_l
(
"alpha"
,
"alpha"
));
CU_ASSERT
(
util
::
strieq_l
(
"alpha"
,
"AlPhA"
));
CU_ASSERT
(
util
::
strieq_l
(
""
,
""
));
CU_ASSERT
(
!
util
::
strieq_l
(
"alpha"
,
"AlPhA "
));
CU_ASSERT
(
!
util
::
strieq_l
(
""
,
"AlPhA "
));
}
void
test_util_inp_strlower
(
void
)
{
...
...
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