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
208d7156
Commit
208d7156
authored
Nov 04, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Add missing mandatory SP after status code
parent
25fbc7b4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
70 deletions
+94
-70
src/HttpServer.cc
src/HttpServer.cc
+6
-1
src/asio_server_request_handler.cc
src/asio_server_request_handler.cc
+8
-3
src/http2.cc
src/http2.cc
+51
-51
src/http2.h
src/http2.h
+3
-3
src/shrpx_http.cc
src/shrpx_http.cc
+5
-2
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+9
-4
src/shrpx_spdy_upstream.cc
src/shrpx_spdy_upstream.cc
+12
-6
No files found.
src/HttpServer.cc
View file @
208d7156
...
...
@@ -1921,13 +1921,18 @@ namespace {
FileEntry
make_status_body
(
int
status
,
uint16_t
port
)
{
BlockAllocator
balloc
(
1024
,
1024
);
auto
status_string
=
http2
::
get_status_string
(
balloc
,
status
);
auto
status_string
=
http2
::
stringify_status
(
balloc
,
status
);
auto
reason_pharase
=
http2
::
get_reason_phrase
(
status
);
std
::
string
body
;
body
=
"<html><head><title>"
;
body
+=
status_string
;
body
+=
' '
;
body
+=
reason_pharase
;
body
+=
"</title></head><body><h1>"
;
body
+=
status_string
;
body
+=
' '
;
body
+=
reason_pharase
;
body
+=
"</h1><hr><address>"
;
body
+=
NGHTTPD_SERVER
;
body
+=
" at port "
;
...
...
src/asio_server_request_handler.cc
View file @
208d7156
...
...
@@ -36,11 +36,16 @@ std::string create_html(int status_code) {
BlockAllocator
balloc
(
1024
,
1024
);
std
::
string
res
;
res
.
reserve
(
512
);
auto
status
=
::
nghttp2
::
http2
::
get_status_string
(
balloc
,
status_code
);
auto
status_string
=
::
nghttp2
::
http2
::
stringify_status
(
balloc
,
status_code
);
auto
reason_phrase
=
::
nghttp2
::
http2
::
get_reason_phrase
(
status_code
);
res
+=
R"(<!DOCTYPE html><html lang="en"><title>)"
;
res
+=
status
;
res
+=
status_string
;
res
+=
' '
;
res
+=
reason_phrase
;
res
+=
"</title><body><h1>"
;
res
+=
status
;
res
+=
status_string
;
res
+=
' '
;
res
+=
reason_phrase
;
res
+=
"</h1></body></html>"
;
return
res
;
}
...
...
src/http2.cc
View file @
208d7156
...
...
@@ -30,107 +30,107 @@ namespace nghttp2 {
namespace
http2
{
StringRef
get_
status_string
(
BlockAllocator
&
balloc
,
unsigned
int
status_code
)
{
StringRef
get_
reason_phrase
(
unsigned
int
status_code
)
{
switch
(
status_code
)
{
case
100
:
return
StringRef
::
from_lit
(
"
100
Continue"
);
return
StringRef
::
from_lit
(
"Continue"
);
case
101
:
return
StringRef
::
from_lit
(
"
101
Switching Protocols"
);
return
StringRef
::
from_lit
(
"Switching Protocols"
);
case
200
:
return
StringRef
::
from_lit
(
"
200
OK"
);
return
StringRef
::
from_lit
(
"OK"
);
case
201
:
return
StringRef
::
from_lit
(
"
201
Created"
);
return
StringRef
::
from_lit
(
"Created"
);
case
202
:
return
StringRef
::
from_lit
(
"
202
Accepted"
);
return
StringRef
::
from_lit
(
"Accepted"
);
case
203
:
return
StringRef
::
from_lit
(
"
203
Non-Authoritative Information"
);
return
StringRef
::
from_lit
(
"Non-Authoritative Information"
);
case
204
:
return
StringRef
::
from_lit
(
"
204
No Content"
);
return
StringRef
::
from_lit
(
"No Content"
);
case
205
:
return
StringRef
::
from_lit
(
"
205
Reset Content"
);
return
StringRef
::
from_lit
(
"Reset Content"
);
case
206
:
return
StringRef
::
from_lit
(
"
206
Partial Content"
);
return
StringRef
::
from_lit
(
"Partial Content"
);
case
300
:
return
StringRef
::
from_lit
(
"
300
Multiple Choices"
);
return
StringRef
::
from_lit
(
"Multiple Choices"
);
case
301
:
return
StringRef
::
from_lit
(
"
301
Moved Permanently"
);
return
StringRef
::
from_lit
(
"Moved Permanently"
);
case
302
:
return
StringRef
::
from_lit
(
"
302
Found"
);
return
StringRef
::
from_lit
(
"Found"
);
case
303
:
return
StringRef
::
from_lit
(
"
303
See Other"
);
return
StringRef
::
from_lit
(
"See Other"
);
case
304
:
return
StringRef
::
from_lit
(
"
304
Not Modified"
);
return
StringRef
::
from_lit
(
"Not Modified"
);
case
305
:
return
StringRef
::
from_lit
(
"
305
Use Proxy"
);
// case 306: return StringRef::from_lit("
306
(Unused)");
return
StringRef
::
from_lit
(
"Use Proxy"
);
// case 306: return StringRef::from_lit("(Unused)");
case
307
:
return
StringRef
::
from_lit
(
"
307
Temporary Redirect"
);
return
StringRef
::
from_lit
(
"Temporary Redirect"
);
case
308
:
return
StringRef
::
from_lit
(
"
308
Permanent Redirect"
);
return
StringRef
::
from_lit
(
"Permanent Redirect"
);
case
400
:
return
StringRef
::
from_lit
(
"
400
Bad Request"
);
return
StringRef
::
from_lit
(
"Bad Request"
);
case
401
:
return
StringRef
::
from_lit
(
"
401
Unauthorized"
);
return
StringRef
::
from_lit
(
"Unauthorized"
);
case
402
:
return
StringRef
::
from_lit
(
"
402
Payment Required"
);
return
StringRef
::
from_lit
(
"Payment Required"
);
case
403
:
return
StringRef
::
from_lit
(
"
403
Forbidden"
);
return
StringRef
::
from_lit
(
"Forbidden"
);
case
404
:
return
StringRef
::
from_lit
(
"
404
Not Found"
);
return
StringRef
::
from_lit
(
"Not Found"
);
case
405
:
return
StringRef
::
from_lit
(
"
405
Method Not Allowed"
);
return
StringRef
::
from_lit
(
"Method Not Allowed"
);
case
406
:
return
StringRef
::
from_lit
(
"
406
Not Acceptable"
);
return
StringRef
::
from_lit
(
"Not Acceptable"
);
case
407
:
return
StringRef
::
from_lit
(
"
407
Proxy Authentication Required"
);
return
StringRef
::
from_lit
(
"Proxy Authentication Required"
);
case
408
:
return
StringRef
::
from_lit
(
"
408
Request Timeout"
);
return
StringRef
::
from_lit
(
"Request Timeout"
);
case
409
:
return
StringRef
::
from_lit
(
"
409
Conflict"
);
return
StringRef
::
from_lit
(
"Conflict"
);
case
410
:
return
StringRef
::
from_lit
(
"
410
Gone"
);
return
StringRef
::
from_lit
(
"Gone"
);
case
411
:
return
StringRef
::
from_lit
(
"
411
Length Required"
);
return
StringRef
::
from_lit
(
"Length Required"
);
case
412
:
return
StringRef
::
from_lit
(
"
412
Precondition Failed"
);
return
StringRef
::
from_lit
(
"Precondition Failed"
);
case
413
:
return
StringRef
::
from_lit
(
"
413
Payload Too Large"
);
return
StringRef
::
from_lit
(
"Payload Too Large"
);
case
414
:
return
StringRef
::
from_lit
(
"
414
URI Too Long"
);
return
StringRef
::
from_lit
(
"URI Too Long"
);
case
415
:
return
StringRef
::
from_lit
(
"
415
Unsupported Media Type"
);
return
StringRef
::
from_lit
(
"Unsupported Media Type"
);
case
416
:
return
StringRef
::
from_lit
(
"
416
Requested Range Not Satisfiable"
);
return
StringRef
::
from_lit
(
"Requested Range Not Satisfiable"
);
case
417
:
return
StringRef
::
from_lit
(
"
417
Expectation Failed"
);
return
StringRef
::
from_lit
(
"Expectation Failed"
);
case
421
:
return
StringRef
::
from_lit
(
"
421
Misdirected Request"
);
return
StringRef
::
from_lit
(
"Misdirected Request"
);
case
426
:
return
StringRef
::
from_lit
(
"
426
Upgrade Required"
);
return
StringRef
::
from_lit
(
"Upgrade Required"
);
case
428
:
return
StringRef
::
from_lit
(
"
428
Precondition Required"
);
return
StringRef
::
from_lit
(
"Precondition Required"
);
case
429
:
return
StringRef
::
from_lit
(
"
429
Too Many Requests"
);
return
StringRef
::
from_lit
(
"Too Many Requests"
);
case
431
:
return
StringRef
::
from_lit
(
"
431
Request Header Fields Too Large"
);
return
StringRef
::
from_lit
(
"Request Header Fields Too Large"
);
case
451
:
return
StringRef
::
from_lit
(
"
451
Unavailable For Legal Reasons"
);
return
StringRef
::
from_lit
(
"Unavailable For Legal Reasons"
);
case
500
:
return
StringRef
::
from_lit
(
"
500
Internal Server Error"
);
return
StringRef
::
from_lit
(
"Internal Server Error"
);
case
501
:
return
StringRef
::
from_lit
(
"
501
Not Implemented"
);
return
StringRef
::
from_lit
(
"Not Implemented"
);
case
502
:
return
StringRef
::
from_lit
(
"
502
Bad Gateway"
);
return
StringRef
::
from_lit
(
"Bad Gateway"
);
case
503
:
return
StringRef
::
from_lit
(
"
503
Service Unavailable"
);
return
StringRef
::
from_lit
(
"Service Unavailable"
);
case
504
:
return
StringRef
::
from_lit
(
"
504
Gateway Timeout"
);
return
StringRef
::
from_lit
(
"Gateway Timeout"
);
case
505
:
return
StringRef
::
from_lit
(
"
505
HTTP Version Not Supported"
);
return
StringRef
::
from_lit
(
"HTTP Version Not Supported"
);
case
511
:
return
StringRef
::
from_lit
(
"
511
Network Authentication Required"
);
return
StringRef
::
from_lit
(
"Network Authentication Required"
);
default:
return
util
::
make_string_ref_uint
(
balloc
,
status_code
)
;
return
StringRef
{}
;
}
}
...
...
src/http2.h
View file @
208d7156
...
...
@@ -94,9 +94,9 @@ using HeaderRefs = std::vector<HeaderRef>;
namespace
http2
{
// Returns
string version of |status code| followed by reason
//
string. (e.g., "404 Not Found")
.
StringRef
get_
status_string
(
BlockAllocator
&
balloc
,
unsigned
int
status_code
);
// Returns
reason-phrase for given |status code|. If there is no
//
known reason-phrase for the given code, returns empty string
.
StringRef
get_
reason_phrase
(
unsigned
int
status_code
);
// Returns string version of |status_code|. (e.g., "404")
StringRef
stringify_status
(
BlockAllocator
&
balloc
,
unsigned
int
status_code
);
...
...
src/shrpx_http.cc
View file @
208d7156
...
...
@@ -45,11 +45,14 @@ StringRef create_error_html(BlockAllocator &balloc, unsigned int http_status) {
}
}
auto
status_string
=
http2
::
get_status_string
(
balloc
,
http_status
);
auto
status_string
=
http2
::
stringify_status
(
balloc
,
http_status
);
auto
reason_phrase
=
http2
::
get_reason_phrase
(
http_status
);
return
concat_string_ref
(
balloc
,
StringRef
::
from_lit
(
R"(<!DOCTYPE html><html lang="en"><title>)"
),
status_string
,
StringRef
::
from_lit
(
"</title><body><h1>"
),
status_string
,
status_string
,
StringRef
::
from_lit
(
" "
),
reason_phrase
,
StringRef
::
from_lit
(
"</title><body><h1>"
),
status_string
,
StringRef
::
from_lit
(
" "
),
reason_phrase
,
StringRef
::
from_lit
(
"</h1><footer>"
),
httpconf
.
server_name
,
StringRef
::
from_lit
(
"</footer></body></html>"
));
}
...
...
src/shrpx_https_upstream.cc
View file @
208d7156
...
...
@@ -863,7 +863,9 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body,
auto
output
=
downstream
->
get_response_buf
();
output
->
append
(
"HTTP/1.1 "
);
output
->
append
(
http2
::
get_status_string
(
balloc
,
resp
.
http_status
));
output
->
append
(
http2
::
stringify_status
(
balloc
,
resp
.
http_status
));
output
->
append
(
' '
);
output
->
append
(
http2
::
get_reason_phrase
(
resp
.
http_status
));
output
->
append
(
"
\r\n
"
);
for
(
auto
&
kv
:
resp
.
fs
.
headers
())
{
...
...
@@ -923,8 +925,9 @@ void HttpsUpstream::error_reply(unsigned int status_code) {
auto
output
=
downstream
->
get_response_buf
();
output
->
append
(
"HTTP/1.1 "
);
auto
status_str
=
http2
::
get_status_string
(
balloc
,
status_code
);
output
->
append
(
status_str
);
output
->
append
(
http2
::
stringify_status
(
balloc
,
status_code
));
output
->
append
(
' '
);
output
->
append
(
http2
::
get_reason_phrase
(
status_code
));
output
->
append
(
"
\r\n
Server: "
);
output
->
append
(
get_config
()
->
http
.
server_name
);
output
->
append
(
"
\r\n
Content-Length: "
);
...
...
@@ -1011,7 +1014,9 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
buf
->
append
(
"."
);
buf
->
append
(
util
::
utos
(
req
.
http_minor
));
buf
->
append
(
" "
);
buf
->
append
(
http2
::
get_status_string
(
balloc
,
resp
.
http_status
));
buf
->
append
(
http2
::
stringify_status
(
balloc
,
resp
.
http_status
));
buf
->
append
(
' '
);
buf
->
append
(
http2
::
get_reason_phrase
(
resp
.
http_status
));
buf
->
append
(
"
\r\n
"
);
auto
config
=
get_config
();
...
...
src/shrpx_spdy_upstream.cc
View file @
208d7156
...
...
@@ -918,7 +918,9 @@ int SpdyUpstream::send_reply(Downstream *downstream, const uint8_t *body,
const
auto
&
resp
=
downstream
->
response
();
auto
&
balloc
=
downstream
->
get_block_allocator
();
auto
status_string
=
http2
::
get_status_string
(
balloc
,
resp
.
http_status
);
auto
status_line
=
concat_string_ref
(
balloc
,
http2
::
stringify_status
(
balloc
,
resp
.
http_status
),
StringRef
::
from_lit
(
" "
),
http2
::
get_reason_phrase
(
resp
.
http_status
));
const
auto
&
headers
=
resp
.
fs
.
headers
();
...
...
@@ -931,7 +933,7 @@ int SpdyUpstream::send_reply(Downstream *downstream, const uint8_t *body,
httpconf
.
add_response_headers
.
size
()
*
2
+
1
);
nva
.
push_back
(
":status"
);
nva
.
push_back
(
status_
string
.
c_str
());
nva
.
push_back
(
status_
line
.
c_str
());
nva
.
push_back
(
":version"
);
nva
.
push_back
(
"HTTP/1.1"
);
...
...
@@ -999,9 +1001,11 @@ int SpdyUpstream::error_reply(Downstream *downstream,
lgconf
->
update_tstamp
(
std
::
chrono
::
system_clock
::
now
());
auto
content_length
=
util
::
make_string_ref_uint
(
balloc
,
html
.
size
());
auto
status_string
=
http2
::
get_status_string
(
balloc
,
status_code
);
auto
status_line
=
concat_string_ref
(
balloc
,
http2
::
stringify_status
(
balloc
,
status_code
),
StringRef
::
from_lit
(
" "
),
http2
::
get_reason_phrase
(
status_code
));
const
char
*
nv
[]
=
{
":status"
,
status_
string
.
c_str
(),
const
char
*
nv
[]
=
{
":status"
,
status_
line
.
c_str
(),
":version"
,
"http/1.1"
,
"content-type"
,
"text/html; charset=UTF-8"
,
"server"
,
get_config
()
->
http
.
server_name
.
c_str
(),
...
...
@@ -1104,9 +1108,11 @@ int SpdyUpstream::on_downstream_header_complete(Downstream *downstream) {
size_t
hdidx
=
0
;
std
::
string
via_value
;
auto
status_string
=
http2
::
get_status_string
(
balloc
,
resp
.
http_status
);
auto
status_line
=
concat_string_ref
(
balloc
,
http2
::
stringify_status
(
balloc
,
resp
.
http_status
),
StringRef
::
from_lit
(
" "
),
http2
::
get_reason_phrase
(
resp
.
http_status
));
nv
[
hdidx
++
]
=
":status"
;
nv
[
hdidx
++
]
=
status_
string
.
c_str
();
nv
[
hdidx
++
]
=
status_
line
.
c_str
();
nv
[
hdidx
++
]
=
":version"
;
nv
[
hdidx
++
]
=
"HTTP/1.1"
;
for
(
auto
&
hd
:
resp
.
fs
.
headers
())
{
...
...
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