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
b68be1e1
Commit
b68be1e1
authored
Feb 21, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Make token of type int32_t; we have no reason to use int16_t
parent
f2a72757
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
62 deletions
+32
-62
src/http2.cc
src/http2.cc
+8
-8
src/http2.h
src/http2.h
+10
-10
src/nghttp.cc
src/nghttp.cc
+2
-29
src/nghttp.h
src/nghttp.h
+2
-5
src/shrpx_downstream.cc
src/shrpx_downstream.cc
+6
-6
src/shrpx_downstream.h
src/shrpx_downstream.h
+4
-4
No files found.
src/http2.cc
View file @
b68be1e1
...
...
@@ -271,7 +271,7 @@ void copy_url_component(std::string &dest, const http_parser_url *u, int field,
Headers
::
value_type
to_header
(
const
uint8_t
*
name
,
size_t
namelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
bool
no_index
,
int
16
_t
token
)
{
bool
no_index
,
int
32
_t
token
)
{
return
Header
(
std
::
string
(
reinterpret_cast
<
const
char
*>
(
name
),
namelen
),
std
::
string
(
reinterpret_cast
<
const
char
*>
(
value
),
valuelen
),
no_index
,
token
);
...
...
@@ -279,7 +279,7 @@ Headers::value_type to_header(const uint8_t *name, size_t namelen,
void
add_header
(
Headers
&
nva
,
const
uint8_t
*
name
,
size_t
namelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
bool
no_index
,
int
16
_t
token
)
{
int
32
_t
token
)
{
if
(
valuelen
>
0
)
{
size_t
i
,
j
;
for
(
i
=
0
;
i
<
valuelen
&&
(
value
[
i
]
==
' '
||
value
[
i
]
==
'\t'
);
++
i
)
...
...
@@ -760,7 +760,7 @@ void init_hdidx(HeaderIndex &hdidx) {
std
::
fill
(
std
::
begin
(
hdidx
),
std
::
end
(
hdidx
),
-
1
);
}
void
index_header
(
HeaderIndex
&
hdidx
,
int
16
_t
token
,
size_t
idx
)
{
void
index_header
(
HeaderIndex
&
hdidx
,
int
32
_t
token
,
size_t
idx
)
{
if
(
token
==
-
1
)
{
return
;
}
...
...
@@ -769,7 +769,7 @@ void index_header(HeaderIndex &hdidx, int16_t token, size_t idx) {
}
bool
check_http2_request_pseudo_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
)
{
int
32
_t
token
)
{
switch
(
token
)
{
case
HD__AUTHORITY
:
case
HD__METHOD
:
...
...
@@ -782,7 +782,7 @@ bool check_http2_request_pseudo_header(const HeaderIndex &hdidx,
}
bool
check_http2_response_pseudo_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
)
{
int
32
_t
token
)
{
switch
(
token
)
{
case
HD__STATUS
:
return
hdidx
[
token
]
==
-
1
;
...
...
@@ -791,7 +791,7 @@ bool check_http2_response_pseudo_header(const HeaderIndex &hdidx,
}
}
bool
http2_header_allowed
(
int
16
_t
token
)
{
bool
http2_header_allowed
(
int
32
_t
token
)
{
switch
(
token
)
{
case
HD_CONNECTION
:
case
HD_KEEP_ALIVE
:
...
...
@@ -813,7 +813,7 @@ bool http2_mandatory_request_headers_presence(const HeaderIndex &hdidx) {
return
true
;
}
const
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
,
const
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
32
_t
token
,
const
Headers
&
nva
)
{
auto
i
=
hdidx
[
token
];
if
(
i
==
-
1
)
{
...
...
@@ -822,7 +822,7 @@ const Headers::value_type *get_header(const HeaderIndex &hdidx, int16_t token,
return
&
nva
[
i
];
}
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
,
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
32
_t
token
,
Headers
&
nva
)
{
auto
i
=
hdidx
[
token
];
if
(
i
==
-
1
)
{
...
...
src/http2.h
View file @
b68be1e1
...
...
@@ -44,7 +44,7 @@ namespace nghttp2 {
struct
Header
{
Header
(
std
::
string
name
,
std
::
string
value
,
bool
no_index
=
false
,
int
16
_t
token
=
-
1
)
int
32
_t
token
=
-
1
)
:
name
(
std
::
move
(
name
)),
value
(
std
::
move
(
value
)),
token
(
token
),
...
...
@@ -62,7 +62,7 @@ struct Header {
std
::
string
name
;
std
::
string
value
;
int
16
_t
token
;
int
32
_t
token
;
bool
no_index
;
};
...
...
@@ -89,14 +89,14 @@ void copy_url_component(std::string &dest, const http_parser_url *u, int field,
Headers
::
value_type
to_header
(
const
uint8_t
*
name
,
size_t
namelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
bool
no_index
,
int
16
_t
token
);
bool
no_index
,
int
32
_t
token
);
// Add name/value pairs to |nva|. If |no_index| is true, this
// name/value pair won't be indexed when it is forwarded to the next
// hop. This function strips white spaces around |value|.
void
add_header
(
Headers
&
nva
,
const
uint8_t
*
name
,
size_t
namelen
,
const
uint8_t
*
value
,
size_t
valuelen
,
bool
no_index
,
int
16
_t
token
);
int
32
_t
token
);
// Returns pointer to the entry in |nva| which has name |name|. If
// more than one entries which have the name |name|, last occurrence
...
...
@@ -277,30 +277,30 @@ int lookup_token(const std::string &name);
// array containing at least HD_MAXIDX elements.
void
init_hdidx
(
HeaderIndex
&
hdidx
);
// Indexes header |token| using index |idx|.
void
index_header
(
HeaderIndex
&
hdidx
,
int
16
_t
token
,
size_t
idx
);
void
index_header
(
HeaderIndex
&
hdidx
,
int
32
_t
token
,
size_t
idx
);
// Returns true if HTTP/2 request pseudo header |token| is not indexed
// yet and not -1.
bool
check_http2_request_pseudo_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
);
bool
check_http2_request_pseudo_header
(
const
HeaderIndex
&
hdidx
,
int
32
_t
token
);
// Returns true if HTTP/2 response pseudo header |token| is not
// indexed yet and not -1.
bool
check_http2_response_pseudo_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
);
int
32
_t
token
);
// Returns true if header field denoted by |token| is allowed for
// HTTP/2.
bool
http2_header_allowed
(
int
16
_t
token
);
bool
http2_header_allowed
(
int
32
_t
token
);
// Returns true that |hdidx| contains mandatory HTTP/2 request
// headers.
bool
http2_mandatory_request_headers_presence
(
const
HeaderIndex
&
hdidx
);
// Returns header denoted by |token| using index |hdidx|.
const
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
,
const
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
32
_t
token
,
const
Headers
&
nva
);
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
16
_t
token
,
Headers
::
value_type
*
get_header
(
const
HeaderIndex
&
hdidx
,
int
32
_t
token
,
Headers
&
nva
);
struct
LinkHeader
{
...
...
src/nghttp.cc
View file @
b68be1e1
...
...
@@ -273,34 +273,7 @@ bool Request::is_ipv6_literal_addr() const {
}
}
bool
Request
::
response_pseudo_header_allowed
(
int16_t
token
)
const
{
if
(
!
res_nva
.
empty
()
&&
res_nva
.
back
().
name
.
c_str
()[
0
]
!=
':'
)
{
return
false
;
}
switch
(
token
)
{
case
http2
:
:
HD__STATUS
:
return
res_hdidx
[
token
]
==
-
1
;
default:
return
false
;
}
}
bool
Request
::
push_request_pseudo_header_allowed
(
int16_t
token
)
const
{
if
(
!
req_nva
.
empty
()
&&
req_nva
.
back
().
name
.
c_str
()[
0
]
!=
':'
)
{
return
false
;
}
switch
(
token
)
{
case
http2
:
:
HD__AUTHORITY
:
case
http2
:
:
HD__METHOD
:
case
http2
:
:
HD__PATH
:
case
http2
:
:
HD__SCHEME
:
return
req_hdidx
[
token
]
==
-
1
;
default:
return
false
;
}
}
Headers
::
value_type
*
Request
::
get_res_header
(
int16_t
token
)
{
Headers
::
value_type
*
Request
::
get_res_header
(
int32_t
token
)
{
auto
idx
=
res_hdidx
[
token
];
if
(
idx
==
-
1
)
{
return
nullptr
;
...
...
@@ -308,7 +281,7 @@ Headers::value_type *Request::get_res_header(int16_t token) {
return
&
res_nva
[
idx
];
}
Headers
::
value_type
*
Request
::
get_req_header
(
int
16
_t
token
)
{
Headers
::
value_type
*
Request
::
get_req_header
(
int
32
_t
token
)
{
auto
idx
=
req_hdidx
[
token
];
if
(
idx
==
-
1
)
{
return
nullptr
;
...
...
src/nghttp.h
View file @
b68be1e1
...
...
@@ -125,11 +125,8 @@ struct Request {
bool
is_ipv6_literal_addr
()
const
;
bool
response_pseudo_header_allowed
(
int16_t
token
)
const
;
bool
push_request_pseudo_header_allowed
(
int16_t
token
)
const
;
Headers
::
value_type
*
get_res_header
(
int16_t
token
);
Headers
::
value_type
*
get_req_header
(
int16_t
token
);
Headers
::
value_type
*
get_res_header
(
int32_t
token
);
Headers
::
value_type
*
get_req_header
(
int32_t
token
);
void
record_request_start_time
();
void
record_response_start_time
();
...
...
src/shrpx_downstream.cc
View file @
b68be1e1
...
...
@@ -331,7 +331,7 @@ void Downstream::crumble_request_cookie(std::vector<nghttp2_nv> &nva) {
namespace
{
void
add_header
(
bool
&
key_prev
,
size_t
&
sum
,
Headers
&
headers
,
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
,
int
16
_t
token
)
{
int
32
_t
token
)
{
key_prev
=
true
;
sum
+=
name
.
size
()
+
value
.
size
();
headers
.
emplace_back
(
name
.
str
(),
value
.
str
(),
no_index
,
token
);
...
...
@@ -340,7 +340,7 @@ void add_header(bool &key_prev, size_t &sum, Headers &headers,
namespace
{
void
add_header
(
size_t
&
sum
,
Headers
&
headers
,
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
,
int
16
_t
token
)
{
const
StringRef
&
value
,
bool
no_index
,
int
32
_t
token
)
{
sum
+=
name
.
size
()
+
value
.
size
();
headers
.
emplace_back
(
name
.
str
(),
value
.
str
(),
no_index
,
token
);
}
...
...
@@ -388,7 +388,7 @@ int FieldStore::parse_content_length() {
return
0
;
}
const
Headers
::
value_type
*
FieldStore
::
header
(
int
16
_t
token
)
const
{
const
Headers
::
value_type
*
FieldStore
::
header
(
int
32
_t
token
)
const
{
for
(
auto
it
=
headers_
.
rbegin
();
it
!=
headers_
.
rend
();
++
it
)
{
auto
&
kv
=
*
it
;
if
(
kv
.
token
==
token
)
{
...
...
@@ -398,7 +398,7 @@ const Headers::value_type *FieldStore::header(int16_t token) const {
return
nullptr
;
}
Headers
::
value_type
*
FieldStore
::
header
(
int
16
_t
token
)
{
Headers
::
value_type
*
FieldStore
::
header
(
int
32
_t
token
)
{
for
(
auto
it
=
headers_
.
rbegin
();
it
!=
headers_
.
rend
();
++
it
)
{
auto
&
kv
=
*
it
;
if
(
kv
.
token
==
token
)
{
...
...
@@ -422,7 +422,7 @@ void FieldStore::add_header_lower(const StringRef &name, const StringRef &value,
}
void
FieldStore
::
add_header_token
(
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
,
int
16
_t
token
)
{
bool
no_index
,
int
32
_t
token
)
{
shrpx
::
add_header
(
buffer_size_
,
headers_
,
name
,
value
,
no_index
,
token
);
}
...
...
@@ -449,7 +449,7 @@ void FieldStore::add_trailer_lower(const StringRef &name,
void
FieldStore
::
add_trailer_token
(
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
,
int
16
_t
token
)
{
int
32
_t
token
)
{
// Header size limit should be applied to all header and trailer
// fields combined.
shrpx
::
add_header
(
buffer_size_
,
trailers_
,
name
,
value
,
no_index
,
token
);
...
...
src/shrpx_downstream.h
View file @
b68be1e1
...
...
@@ -73,8 +73,8 @@ public:
// multiple header have |name| as name, return last occurrence from
// the beginning. If no such header is found, returns nullptr.
// This function must be called after headers are indexed
const
Headers
::
value_type
*
header
(
int
16
_t
token
)
const
;
Headers
::
value_type
*
header
(
int
16
_t
token
);
const
Headers
::
value_type
*
header
(
int
32
_t
token
)
const
;
Headers
::
value_type
*
header
(
int
32
_t
token
);
// Returns pointer to the header field with the name |name|. If no
// such header is found, returns nullptr.
const
Headers
::
value_type
*
header
(
const
StringRef
&
name
)
const
;
...
...
@@ -82,7 +82,7 @@ public:
void
add_header_lower
(
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
);
void
add_header_token
(
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
,
int
16
_t
token
);
bool
no_index
,
int
32
_t
token
);
void
append_last_header_key
(
const
char
*
data
,
size_t
len
);
void
append_last_header_value
(
const
char
*
data
,
size_t
len
);
...
...
@@ -99,7 +99,7 @@ public:
void
add_trailer_lower
(
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
);
void
add_trailer_token
(
const
StringRef
&
name
,
const
StringRef
&
value
,
bool
no_index
,
int
16
_t
token
);
bool
no_index
,
int
32
_t
token
);
void
append_last_trailer_key
(
const
char
*
data
,
size_t
len
);
void
append_last_trailer_value
(
const
char
*
data
,
size_t
len
);
...
...
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