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
3ce1c1d3
Commit
3ce1c1d3
authored
Sep 07, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Add date header field to error_reply and send_reply
parent
21a3edfc
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
38 additions
and
1 deletion
+38
-1
genheaderfunc.py
genheaderfunc.py
+1
-0
src/http2.cc
src/http2.cc
+5
-0
src/http2.h
src/http2.h
+1
-0
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+5
-1
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+5
-0
src/shrpx_log_config.cc
src/shrpx_log_config.cc
+1
-0
src/shrpx_log_config.h
src/shrpx_log_config.h
+1
-0
src/shrpx_mruby_module_response.cc
src/shrpx_mruby_module_response.cc
+8
-0
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+4
-0
src/util.h
src/util.h
+7
-0
No files found.
genheaderfunc.py
View file @
3ce1c1d3
...
...
@@ -28,6 +28,7 @@ HEADERS = [
"accept-language"
,
"cache-control"
,
"user-agent"
,
"date"
,
# disallowed h1 headers
'connection'
,
'keep-alive'
,
...
...
src/http2.cc
View file @
3ce1c1d3
...
...
@@ -414,6 +414,11 @@ int lookup_token(const uint8_t *name, size_t namelen) {
break
;
case
4
:
switch
(
name
[
3
])
{
case
'e'
:
if
(
util
::
streq_l
(
"dat"
,
name
,
3
))
{
return
HD_DATE
;
}
break
;
case
'k'
:
if
(
util
::
streq_l
(
"lin"
,
name
,
3
))
{
return
HD_LINK
;
...
...
src/http2.h
View file @
3ce1c1d3
...
...
@@ -207,6 +207,7 @@ enum {
HD_CONNECTION
,
HD_CONTENT_LENGTH
,
HD_COOKIE
,
HD_DATE
,
HD_EXPECT
,
HD_HOST
,
HD_HTTP2_SETTINGS
,
...
...
src/shrpx_http2_upstream.cc
View file @
3ce1c1d3
...
...
@@ -1238,13 +1238,17 @@ int Http2Upstream::error_reply(Downstream *downstream,
data_prd
.
source
.
ptr
=
downstream
;
data_prd
.
read_callback
=
downstream_data_read_callback
;
auto
lgconf
=
log_config
();
lgconf
->
update_tstamp
(
std
::
chrono
::
system_clock
::
now
());
auto
content_length
=
util
::
utos
(
html
.
size
());
auto
status_code_str
=
util
::
utos
(
status_code
);
auto
nva
=
make_array
(
http2
::
make_nv_ls
(
":status"
,
status_code_str
),
http2
::
make_nv_ll
(
"content-type"
,
"text/html; charset=UTF-8"
),
http2
::
make_nv_lc
(
"server"
,
get_config
()
->
server_name
),
http2
::
make_nv_ls
(
"content-length"
,
content_length
));
http2
::
make_nv_ls
(
"content-length"
,
content_length
),
http2
::
make_nv_ls
(
"date"
,
lgconf
->
time_http_str
));
rv
=
nghttp2_submit_response
(
session_
,
downstream
->
get_stream_id
(),
nva
.
data
(),
nva
.
size
(),
&
data_prd
);
...
...
src/shrpx_https_upstream.cc
View file @
3ce1c1d3
...
...
@@ -857,6 +857,11 @@ void HttpsUpstream::error_reply(unsigned int status_code) {
output
->
append
(
"
\r\n
Content-Length: "
);
auto
cl
=
util
::
utos
(
html
.
size
());
output
->
append
(
cl
.
c_str
(),
cl
.
size
());
output
->
append
(
"
\r\n
Date: "
);
auto
lgconf
=
log_config
();
lgconf
->
update_tstamp
(
std
::
chrono
::
system_clock
::
now
());
auto
&
date
=
lgconf
->
time_http_str
;
output
->
append
(
date
.
c_str
(),
date
.
size
());
output
->
append
(
"
\r\n
Content-Type: text/html; "
"charset=UTF-8
\r\n
Connection: close
\r\n\r\n
"
);
output
->
append
(
html
.
c_str
(),
html
.
size
());
...
...
src/shrpx_log_config.cc
View file @
3ce1c1d3
...
...
@@ -64,6 +64,7 @@ LogConfig::update_tstamp(const std::chrono::system_clock::time_point &now) {
time_local_str
=
util
::
format_common_log
(
now
);
time_iso8601_str
=
util
::
format_iso8601
(
now
);
time_http_str
=
util
::
format_http_date
(
now
);
}
}
// namespace shrpx
src/shrpx_log_config.h
View file @
3ce1c1d3
...
...
@@ -35,6 +35,7 @@ struct LogConfig {
std
::
chrono
::
system_clock
::
time_point
time_str_updated_
;
std
::
string
time_local_str
;
std
::
string
time_iso8601_str
;
std
::
string
time_http_str
;
int
accesslog_fd
;
int
errorlog_fd
;
// true if errorlog_fd is referring to a terminal.
...
...
src/shrpx_mruby_module_response.cc
View file @
3ce1c1d3
...
...
@@ -210,6 +210,14 @@ mrb_value response_return(mrb_state *mrb, mrb_value self) {
}
downstream
->
set_response_content_length
(
bodylen
);
auto
date
=
downstream
->
get_response_header
(
http2
::
HD_DATE
);
if
(
!
date
)
{
auto
lgconf
=
log_config
();
lgconf
->
update_tstamp
(
std
::
chrono
::
system_clock
::
now
());
downstream
->
add_response_header
(
"date"
,
lgconf
->
time_http_str
,
http2
::
HD_DATE
);
}
auto
upstream
=
downstream
->
get_upstream
();
rv
=
upstream
->
send_reply
(
downstream
,
body
,
bodylen
);
...
...
src/shrpx_spdy_upstream.cc
View file @
3ce1c1d3
...
...
@@ -881,6 +881,9 @@ int SpdyUpstream::error_reply(Downstream *downstream,
data_prd
.
source
.
ptr
=
downstream
;
data_prd
.
read_callback
=
spdy_data_read_callback
;
auto
lgconf
=
log_config
();
lgconf
->
update_tstamp
(
std
::
chrono
::
system_clock
::
now
());
std
::
string
content_length
=
util
::
utos
(
html
.
size
());
std
::
string
status_string
=
http2
::
get_status_string
(
status_code
);
const
char
*
nv
[]
=
{
":status"
,
status_string
.
c_str
(),
...
...
@@ -888,6 +891,7 @@ int SpdyUpstream::error_reply(Downstream *downstream,
"content-type"
,
"text/html; charset=UTF-8"
,
"server"
,
get_config
()
->
server_name
,
"content-length"
,
content_length
.
c_str
(),
"date"
,
lgconf
->
time_http_str
.
c_str
(),
nullptr
};
rv
=
spdylay_submit_response
(
session_
,
downstream
->
get_stream_id
(),
nv
,
...
...
src/util.h
View file @
3ce1c1d3
...
...
@@ -588,6 +588,13 @@ template <typename T> std::string format_iso8601(const T &tp) {
return
iso8601_date
(
t
.
count
());
}
// Returns given time |tp| in HTTP date format.
template
<
typename
T
>
std
::
string
format_http_date
(
const
T
&
tp
)
{
auto
t
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
tp
.
time_since_epoch
());
return
http_date
(
t
.
count
());
}
// Return the system precision of the template parameter |Clock| as
// a nanosecond value of type |Rep|
template
<
typename
Clock
,
typename
Rep
>
Rep
clock_precision
()
{
...
...
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