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
dd741a58
Commit
dd741a58
authored
Mar 03, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use header_map instead of wrapping it
parent
26304546
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
33 additions
and
99 deletions
+33
-99
examples/asio-cl.cc
examples/asio-cl.cc
+2
-2
src/asio_client_request.cc
src/asio_client_request.cc
+1
-1
src/asio_client_request_impl.cc
src/asio_client_request_impl.cc
+3
-3
src/asio_client_request_impl.h
src/asio_client_request_impl.h
+4
-4
src/asio_client_response.cc
src/asio_client_response.cc
+1
-1
src/asio_client_response_impl.cc
src/asio_client_response_impl.cc
+2
-2
src/asio_client_response_impl.h
src/asio_client_response_impl.h
+3
-3
src/asio_client_session.cc
src/asio_client_session.cc
+3
-3
src/asio_client_session_impl.cc
src/asio_client_session_impl.cc
+8
-8
src/asio_client_session_impl.h
src/asio_client_session_impl.h
+1
-1
src/asio_common.cc
src/asio_common.cc
+0
-41
src/includes/nghttp2/asio_http2.h
src/includes/nghttp2/asio_http2.h
+5
-30
No files found.
examples/asio-cl.cc
View file @
dd741a58
...
@@ -36,8 +36,8 @@ using boost::asio::ip::tcp;
...
@@ -36,8 +36,8 @@ using boost::asio::ip::tcp;
using
namespace
nghttp2
::
asio_http2
;
using
namespace
nghttp2
::
asio_http2
;
using
namespace
nghttp2
::
asio_http2
::
client
;
using
namespace
nghttp2
::
asio_http2
::
client
;
void
print_header
(
const
h
ttp_header
&
h
)
{
void
print_header
(
const
h
eader_map
&
h
)
{
for
(
auto
&
kv
:
h
.
items
()
)
{
for
(
auto
&
kv
:
h
)
{
std
::
cerr
<<
kv
.
first
<<
": "
<<
kv
.
second
.
value
<<
"
\n
"
;
std
::
cerr
<<
kv
.
first
<<
": "
<<
kv
.
second
.
value
<<
"
\n
"
;
}
}
std
::
cerr
<<
std
::
endl
;
std
::
cerr
<<
std
::
endl
;
...
...
src/asio_client_request.cc
View file @
dd741a58
...
@@ -54,7 +54,7 @@ const std::string &request::authority() const { return impl_->authority(); }
...
@@ -54,7 +54,7 @@ const std::string &request::authority() const { return impl_->authority(); }
const
std
::
string
&
request
::
host
()
const
{
return
impl_
->
host
();
}
const
std
::
string
&
request
::
host
()
const
{
return
impl_
->
host
();
}
const
h
ttp_header
&
request
::
header
()
const
{
return
impl_
->
header
();
}
const
h
eader_map
&
request
::
header
()
const
{
return
impl_
->
header
();
}
request_impl
&
request
::
impl
()
{
return
*
impl_
;
}
request_impl
&
request
::
impl
()
{
return
*
impl_
;
}
...
...
src/asio_client_request_impl.cc
View file @
dd741a58
...
@@ -68,11 +68,11 @@ read_cb::result_type request_impl::call_on_read(uint8_t *buf, std::size_t len) {
...
@@ -68,11 +68,11 @@ read_cb::result_type request_impl::call_on_read(uint8_t *buf, std::size_t len) {
return
read_cb
::
result_type
{};
return
read_cb
::
result_type
{};
}
}
void
request_impl
::
header
(
h
ttp_header
h
)
{
header_
=
std
::
move
(
h
);
}
void
request_impl
::
header
(
h
eader_map
h
)
{
header_
=
std
::
move
(
h
);
}
h
ttp_header
&
request_impl
::
header
()
{
return
header_
;
}
h
eader_map
&
request_impl
::
header
()
{
return
header_
;
}
const
h
ttp_header
&
request_impl
::
header
()
const
{
return
header_
;
}
const
h
eader_map
&
request_impl
::
header
()
const
{
return
header_
;
}
void
request_impl
::
stream
(
class
stream
*
strm
)
{
strm_
=
strm
;
}
void
request_impl
::
stream
(
class
stream
*
strm
)
{
strm_
=
strm
;
}
...
...
src/asio_client_request_impl.h
View file @
dd741a58
...
@@ -57,9 +57,9 @@ public:
...
@@ -57,9 +57,9 @@ public:
void
on_read
(
read_cb
cb
);
void
on_read
(
read_cb
cb
);
read_cb
::
result_type
call_on_read
(
uint8_t
*
buf
,
std
::
size_t
len
);
read_cb
::
result_type
call_on_read
(
uint8_t
*
buf
,
std
::
size_t
len
);
void
header
(
h
ttp_header
h
);
void
header
(
h
eader_map
h
);
h
ttp_header
&
header
();
h
eader_map
&
header
();
const
h
ttp_header
&
header
()
const
;
const
h
eader_map
&
header
()
const
;
void
stream
(
class
stream
*
strm
);
void
stream
(
class
stream
*
strm
);
...
@@ -79,7 +79,7 @@ public:
...
@@ -79,7 +79,7 @@ public:
const
std
::
string
&
host
()
const
;
const
std
::
string
&
host
()
const
;
private:
private:
h
ttp_header
header_
;
h
eader_map
header_
;
response_cb
response_cb_
;
response_cb
response_cb_
;
request_cb
push_request_cb_
;
request_cb
push_request_cb_
;
close_cb
close_cb_
;
close_cb
close_cb_
;
...
...
src/asio_client_response.cc
View file @
dd741a58
...
@@ -42,7 +42,7 @@ int response::status_code() const { return impl_->status_code(); }
...
@@ -42,7 +42,7 @@ int response::status_code() const { return impl_->status_code(); }
int64_t
response
::
content_length
()
const
{
return
impl_
->
content_length
();
}
int64_t
response
::
content_length
()
const
{
return
impl_
->
content_length
();
}
const
h
ttp_header
&
response
::
header
()
const
{
return
impl_
->
header
();
}
const
h
eader_map
&
response
::
header
()
const
{
return
impl_
->
header
();
}
response_impl
&
response
::
impl
()
{
return
*
impl_
;
}
response_impl
&
response
::
impl
()
{
return
*
impl_
;
}
...
...
src/asio_client_response_impl.cc
View file @
dd741a58
...
@@ -48,9 +48,9 @@ void response_impl::content_length(int64_t n) { content_length_ = n; }
...
@@ -48,9 +48,9 @@ void response_impl::content_length(int64_t n) { content_length_ = n; }
int64_t
response_impl
::
content_length
()
const
{
return
content_length_
;
}
int64_t
response_impl
::
content_length
()
const
{
return
content_length_
;
}
h
ttp_header
&
response_impl
::
header
()
{
return
header_
;
}
h
eader_map
&
response_impl
::
header
()
{
return
header_
;
}
const
h
ttp_header
&
response_impl
::
header
()
const
{
return
header_
;
}
const
h
eader_map
&
response_impl
::
header
()
const
{
return
header_
;
}
}
// namespace client
}
// namespace client
}
// namespace asio_http2
}
// namespace asio_http2
...
...
src/asio_client_response_impl.h
View file @
dd741a58
...
@@ -50,13 +50,13 @@ public:
...
@@ -50,13 +50,13 @@ public:
void
content_length
(
int64_t
n
);
void
content_length
(
int64_t
n
);
int64_t
content_length
()
const
;
int64_t
content_length
()
const
;
h
ttp_header
&
header
();
h
eader_map
&
header
();
const
h
ttp_header
&
header
()
const
;
const
h
eader_map
&
header
()
const
;
private:
private:
data_cb
data_cb_
;
data_cb
data_cb_
;
h
ttp_header
header_
;
h
eader_map
header_
;
int64_t
content_length_
;
int64_t
content_length_
;
int
status_code_
;
int
status_code_
;
...
...
src/asio_client_session.cc
View file @
dd741a58
...
@@ -56,20 +56,20 @@ void session::shutdown() { impl_->shutdown(); }
...
@@ -56,20 +56,20 @@ void session::shutdown() { impl_->shutdown(); }
request
*
session
::
submit
(
boost
::
system
::
error_code
&
ec
,
request
*
session
::
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
h
ttp_header
h
)
{
h
eader_map
h
)
{
return
impl_
->
submit
(
ec
,
method
,
uri
,
read_cb
(),
std
::
move
(
h
));
return
impl_
->
submit
(
ec
,
method
,
uri
,
read_cb
(),
std
::
move
(
h
));
}
}
request
*
session
::
submit
(
boost
::
system
::
error_code
&
ec
,
request
*
session
::
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
std
::
string
data
,
h
ttp_header
h
)
{
std
::
string
data
,
h
eader_map
h
)
{
return
impl_
->
submit
(
ec
,
method
,
uri
,
string_reader
(
std
::
move
(
data
)),
return
impl_
->
submit
(
ec
,
method
,
uri
,
string_reader
(
std
::
move
(
data
)),
std
::
move
(
h
));
std
::
move
(
h
));
}
}
request
*
session
::
submit
(
boost
::
system
::
error_code
&
ec
,
request
*
session
::
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
read_cb
cb
,
h
ttp_header
h
)
{
read_cb
cb
,
h
eader_map
h
)
{
return
impl_
->
submit
(
ec
,
method
,
uri
,
std
::
move
(
cb
),
std
::
move
(
h
));
return
impl_
->
submit
(
ec
,
method
,
uri
,
std
::
move
(
cb
),
std
::
move
(
h
));
}
}
...
...
src/asio_client_session_impl.cc
View file @
dd741a58
...
@@ -134,9 +134,9 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
...
@@ -134,9 +134,9 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
res
.
content_length
(
util
::
parse_uint
(
value
,
valuelen
));
res
.
content_length
(
util
::
parse_uint
(
value
,
valuelen
));
}
}
res
.
header
().
add
(
std
::
string
(
name
,
name
+
namelen
),
res
.
header
().
emplace
(
std
::
string
(
name
,
name
+
namelen
),
std
::
string
(
value
,
value
+
valuelen
),
header_value
(
std
::
string
(
value
,
value
+
valuelen
),
flags
&
NGHTTP2_NV_FLAG_NO_INDEX
);
flags
&
NGHTTP2_NV_FLAG_NO_INDEX
)
);
}
}
break
;
break
;
}
}
...
@@ -167,9 +167,9 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
...
@@ -167,9 +167,9 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
req
.
host
(
std
::
string
(
value
,
value
+
valuelen
));
req
.
host
(
std
::
string
(
value
,
value
+
valuelen
));
// fall through
// fall through
default:
default:
req
.
header
().
add
(
std
::
string
(
name
,
name
+
namelen
),
req
.
header
().
emplace
(
std
::
string
(
name
,
name
+
namelen
),
std
::
string
(
value
,
value
+
valuelen
),
header_value
(
std
::
string
(
value
,
value
+
valuelen
),
flags
&
NGHTTP2_NV_FLAG_NO_INDEX
);
flags
&
NGHTTP2_NV_FLAG_NO_INDEX
)
);
}
}
break
;
break
;
...
@@ -345,7 +345,7 @@ std::unique_ptr<stream> session_impl::create_stream() {
...
@@ -345,7 +345,7 @@ std::unique_ptr<stream> session_impl::create_stream() {
request
*
session_impl
::
submit
(
boost
::
system
::
error_code
&
ec
,
request
*
session_impl
::
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
read_cb
cb
,
h
ttp_header
h
)
{
read_cb
cb
,
h
eader_map
h
)
{
ec
.
clear
();
ec
.
clear
();
auto
nva
=
std
::
vector
<
nghttp2_nv
>
();
auto
nva
=
std
::
vector
<
nghttp2_nv
>
();
...
@@ -354,7 +354,7 @@ request *session_impl::submit(boost::system::error_code &ec,
...
@@ -354,7 +354,7 @@ request *session_impl::submit(boost::system::error_code &ec,
nva
.
push_back
(
http2
::
make_nv_ll
(
":scheme"
,
"https"
));
nva
.
push_back
(
http2
::
make_nv_ll
(
":scheme"
,
"https"
));
nva
.
push_back
(
http2
::
make_nv_ll
(
":path"
,
"/"
));
nva
.
push_back
(
http2
::
make_nv_ll
(
":path"
,
"/"
));
nva
.
push_back
(
http2
::
make_nv_ll
(
":authority"
,
"localhost:3000"
));
nva
.
push_back
(
http2
::
make_nv_ll
(
":authority"
,
"localhost:3000"
));
for
(
auto
&
kv
:
h
.
items
()
)
{
for
(
auto
&
kv
:
h
)
{
nva
.
push_back
(
nva
.
push_back
(
http2
::
make_nv
(
kv
.
first
,
kv
.
second
.
value
,
kv
.
second
.
sensitive
));
http2
::
make_nv
(
kv
.
first
,
kv
.
second
.
value
,
kv
.
second
.
sensitive
));
}
}
...
...
src/asio_client_session_impl.h
View file @
dd741a58
...
@@ -65,7 +65,7 @@ public:
...
@@ -65,7 +65,7 @@ public:
stream
*
find_stream
(
int32_t
stream_id
);
stream
*
find_stream
(
int32_t
stream_id
);
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
read_cb
cb
,
h
ttp_header
h
);
const
std
::
string
&
uri
,
read_cb
cb
,
h
eader_map
h
);
virtual
tcp
::
socket
&
socket
()
=
0
;
virtual
tcp
::
socket
&
socket
()
=
0
;
virtual
void
read_socket
(
std
::
function
<
virtual
void
read_socket
(
std
::
function
<
...
...
src/asio_common.cc
View file @
dd741a58
...
@@ -57,46 +57,5 @@ read_cb string_reader(std::string data) {
...
@@ -57,46 +57,5 @@ read_cb string_reader(std::string data) {
};
};
}
}
http_header
::
http_header
()
{}
http_header
::
http_header
(
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
header_value
>>
ilist
)
{
for
(
auto
&
kv
:
ilist
)
{
auto
name
=
kv
.
first
;
util
::
inp_strlower
(
name
);
items_
.
emplace
(
std
::
move
(
name
),
kv
.
second
);
}
}
http_header
&
http_header
::
operator
=
(
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
header_value
>>
ilist
)
{
items_
.
clear
();
for
(
auto
&
kv
:
ilist
)
{
auto
name
=
kv
.
first
;
util
::
inp_strlower
(
name
);
items_
.
emplace
(
std
::
move
(
name
),
kv
.
second
);
}
return
*
this
;
}
const
header_map
&
http_header
::
items
()
const
{
return
items_
;
}
void
http_header
::
add
(
std
::
string
name
,
std
::
string
value
,
bool
sensitive
)
{
util
::
inp_strlower
(
name
);
items_
.
emplace
(
name
,
header_value
(
value
,
sensitive
));
}
const
header_value
*
http_header
::
get
(
const
std
::
string
&
name
)
const
{
auto
it
=
items_
.
find
(
name
);
if
(
it
==
std
::
end
(
items_
))
{
return
nullptr
;
}
return
&
(
*
it
).
second
;
}
std
::
size_t
http_header
::
size
()
const
{
return
items_
.
size
();
}
bool
http_header
::
empty
()
const
{
return
items_
.
empty
();
}
}
// namespace asio_http2
}
// namespace asio_http2
}
// namespace nghttp2
}
// namespace nghttp2
src/includes/nghttp2/asio_http2.h
View file @
dd741a58
...
@@ -72,31 +72,6 @@ struct header_value {
...
@@ -72,31 +72,6 @@ struct header_value {
using
header_map
=
std
::
multimap
<
std
::
string
,
header_value
>
;
using
header_map
=
std
::
multimap
<
std
::
string
,
header_value
>
;
class
http_header
{
public:
http_header
();
http_header
(
const
http_header
&
other
)
=
default
;
http_header
(
http_header
&&
other
)
=
default
;
http_header
(
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
header_value
>>
ilist
);
http_header
&
operator
=
(
const
http_header
&
other
)
=
default
;
http_header
&
operator
=
(
http_header
&&
other
)
=
default
;
http_header
&
operator
=
(
std
::
initializer_list
<
std
::
pair
<
std
::
string
,
header_value
>>
ilist
);
const
header_map
&
items
()
const
;
void
add
(
std
::
string
name
,
std
::
string
value
,
bool
sensitive
);
const
header_value
*
get
(
const
std
::
string
&
name
)
const
;
std
::
size_t
size
()
const
;
bool
empty
()
const
;
private:
header_map
items_
;
};
const
boost
::
system
::
error_category
&
nghttp2_category
()
noexcept
;
const
boost
::
system
::
error_category
&
nghttp2_category
()
noexcept
;
typedef
std
::
function
<
void
(
const
uint8_t
*
,
std
::
size_t
)
>
data_cb
;
typedef
std
::
function
<
void
(
const
uint8_t
*
,
std
::
size_t
)
>
data_cb
;
...
@@ -318,7 +293,7 @@ public:
...
@@ -318,7 +293,7 @@ public:
int64_t
content_length
()
const
;
int64_t
content_length
()
const
;
const
h
ttp_header
&
header
()
const
;
const
h
eader_map
&
header
()
const
;
response_impl
&
impl
();
response_impl
&
impl
();
...
@@ -350,7 +325,7 @@ public:
...
@@ -350,7 +325,7 @@ public:
const
std
::
string
&
authority
()
const
;
const
std
::
string
&
authority
()
const
;
const
std
::
string
&
host
()
const
;
const
std
::
string
&
host
()
const
;
const
h
ttp_header
&
header
()
const
;
const
h
eader_map
&
header
()
const
;
request_impl
&
impl
();
request_impl
&
impl
();
...
@@ -375,11 +350,11 @@ public:
...
@@ -375,11 +350,11 @@ public:
void
shutdown
();
void
shutdown
();
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
h
ttp_header
h
=
{});
const
std
::
string
&
uri
,
h
eader_map
h
=
{});
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
std
::
string
data
,
h
ttp_header
h
=
{});
const
std
::
string
&
uri
,
std
::
string
data
,
h
eader_map
h
=
{});
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
request
*
submit
(
boost
::
system
::
error_code
&
ec
,
const
std
::
string
&
method
,
const
std
::
string
&
uri
,
read_cb
cb
,
h
ttp_header
h
=
{});
const
std
::
string
&
uri
,
read_cb
cb
,
h
eader_map
h
=
{});
private:
private:
std
::
unique_ptr
<
session_impl
>
impl_
;
std
::
unique_ptr
<
session_impl
>
impl_
;
...
...
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