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
eaefce37
Commit
eaefce37
authored
Nov 07, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttp: Record request method to output it in har correctly
parent
558934ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
26 deletions
+24
-26
src/nghttp.cc
src/nghttp.cc
+23
-26
src/nghttp.h
src/nghttp.h
+1
-0
No files found.
src/nghttp.cc
View file @
eaefce37
...
...
@@ -392,6 +392,11 @@ int submit_request(HttpClient *client, const Headers &headers, Request *req) {
nva
.
push_back
(
http2
::
make_nv
(
kv
.
name
,
kv
.
value
,
kv
.
no_index
));
}
auto
method
=
http2
::
get_header
(
build_headers
,
":method"
);
assert
(
method
);
req
->
method
=
method
->
value
;
std
::
string
trailer_names
;
if
(
!
config
.
trailer
.
empty
())
{
trailer_names
=
config
.
trailer
[
0
].
name
;
...
...
@@ -808,6 +813,7 @@ int HttpClient::on_upgrade_connect() {
base64
::
encode
(
std
::
begin
(
settings_payload
),
std
::
begin
(
settings_payload
)
+
settings_payloadlen
);
util
::
to_token68
(
token68
);
std
::
string
req
;
if
(
reqvec
[
0
]
->
data_prd
)
{
// If the request contains upload data, use OPTIONS * to upgrade
...
...
@@ -819,25 +825,30 @@ int HttpClient::on_upgrade_connect() {
if
(
meth
==
std
::
end
(
config
.
headers
))
{
req
=
"GET "
;
reqvec
[
0
]
->
method
=
"GET"
;
}
else
{
req
=
(
*
meth
).
value
;
req
+=
" "
;
reqvec
[
0
]
->
method
=
(
*
meth
).
value
;
}
req
+=
reqvec
[
0
]
->
make_reqpath
();
}
auto
headers
=
Headers
{{
"
H
ost"
,
hostport
},
{
"
C
onnection"
,
"Upgrade, HTTP2-Settings"
},
{
"
U
pgrade"
,
NGHTTP2_CLEARTEXT_PROTO_VERSION_ID
},
{
"
HTTP2-S
ettings"
,
token68
},
{
"
A
ccept"
,
"*/*"
},
{
"
User-A
gent"
,
"nghttp2/"
NGHTTP2_VERSION
}};
auto
headers
=
Headers
{{
"
h
ost"
,
hostport
},
{
"
c
onnection"
,
"Upgrade, HTTP2-Settings"
},
{
"
u
pgrade"
,
NGHTTP2_CLEARTEXT_PROTO_VERSION_ID
},
{
"
http2-s
ettings"
,
token68
},
{
"
a
ccept"
,
"*/*"
},
{
"
user-a
gent"
,
"nghttp2/"
NGHTTP2_VERSION
}};
auto
initial_headerslen
=
headers
.
size
();
for
(
auto
&
kv
:
config
.
headers
)
{
size_t
i
;
if
(
kv
.
name
.
empty
()
||
kv
.
name
[
0
]
==
':'
)
{
continue
;
}
for
(
i
=
0
;
i
<
initial_headerslen
;
++
i
)
{
if
(
util
::
strieq
(
kv
.
name
,
headers
[
i
].
name
)
)
{
if
(
kv
.
name
==
headers
[
i
].
name
)
{
headers
[
i
].
value
=
kv
.
value
;
break
;
}
...
...
@@ -845,9 +856,7 @@ int HttpClient::on_upgrade_connect() {
if
(
i
<
initial_headerslen
)
{
continue
;
}
if
(
kv
.
name
.
size
()
!=
0
&&
kv
.
name
[
0
]
!=
':'
)
{
headers
.
emplace_back
(
kv
.
name
,
kv
.
value
,
kv
.
no_index
);
}
headers
.
emplace_back
(
kv
.
name
,
kv
.
value
,
kv
.
no_index
);
}
req
+=
" HTTP/1.1
\r\n
"
;
...
...
@@ -867,9 +876,10 @@ int HttpClient::on_upgrade_connect() {
std
::
cout
<<
" HTTP Upgrade request
\n
"
<<
req
<<
std
::
endl
;
}
// record request time if this is GET request
if
(
!
reqvec
[
0
]
->
data_prd
)
{
// record request time if this is a part of real request.
reqvec
[
0
]
->
record_request_start_time
();
reqvec
[
0
]
->
req_nva
=
std
::
move
(
headers
);
}
on_writefn
=
&
HttpClient
::
noop
;
...
...
@@ -990,13 +1000,7 @@ int HttpClient::connection_made() {
}
// If HEAD is used, that is only when user specified it with -H
// option.
auto
head_request
=
stream_user_data
&&
std
::
find_if
(
std
::
begin
(
config
.
headers
),
std
::
end
(
config
.
headers
),
[](
const
Header
&
kv
)
{
return
util
::
streq_l
(
":method"
,
kv
.
name
)
&&
util
::
streq_l
(
"HEAD"
,
kv
.
value
);
})
!=
std
::
end
(
config
.
headers
);
auto
head_request
=
stream_user_data
&&
stream_user_data
->
method
==
"HEAD"
;
rv
=
nghttp2_session_upgrade2
(
session
,
settings_payload
.
data
(),
settings_payloadlen
,
head_request
,
stream_user_data
);
...
...
@@ -1397,13 +1401,6 @@ void HttpClient::output_har(FILE *outfile) {
auto
request
=
json_object
();
json_object_set_new
(
entry
,
"request"
,
request
);
auto
method_ptr
=
http2
::
get_header
(
req
->
req_nva
,
":method"
);
const
char
*
method
=
"GET"
;
if
(
method_ptr
)
{
method
=
(
*
method_ptr
).
value
.
c_str
();
}
auto
req_headers
=
json_array
();
json_object_set_new
(
request
,
"headers"
,
req_headers
);
...
...
@@ -1415,7 +1412,7 @@ void HttpClient::output_har(FILE *outfile) {
json_object_set_new
(
hd
,
"value"
,
json_string
(
nv
.
value
.
c_str
()));
}
json_object_set_new
(
request
,
"method"
,
json_string
(
method
));
json_object_set_new
(
request
,
"method"
,
json_string
(
req
->
method
.
c_str
()
));
json_object_set_new
(
request
,
"url"
,
json_string
(
req
->
uri
.
c_str
()));
json_object_set_new
(
request
,
"httpVersion"
,
json_string
(
"HTTP/2.0"
));
json_object_set_new
(
request
,
"cookies"
,
json_array
());
...
...
src/nghttp.h
View file @
eaefce37
...
...
@@ -137,6 +137,7 @@ struct Request {
Headers
res_nva
;
Headers
req_nva
;
std
::
string
method
;
// URI without fragment
std
::
string
uri
;
http_parser_url
u
;
...
...
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