Commit cbd878bb authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttp, nghttpd: Allow unit for --header-table-size option

parent 49eeed84
...@@ -2295,7 +2295,10 @@ Options: ...@@ -2295,7 +2295,10 @@ Options:
--no-dep Don't send dependency based priority hint to server. --no-dep Don't send dependency based priority hint to server.
--dep-idle Use idle streams as anchor nodes to express priority. --dep-idle Use idle streams as anchor nodes to express priority.
--version Display version information and exit. --version Display version information and exit.
-h, --help Display this help and exit.)" << std::endl; -h, --help Display this help and exit.
The <SIZE> argument is an integer and an optional unit (e.g., 10K is
10 * 1024). Units are K, M and G (powers of 1024).)" << std::endl;
} }
} // namespace } // namespace
...@@ -2334,7 +2337,6 @@ int main(int argc, char **argv) { ...@@ -2334,7 +2337,6 @@ int main(int argc, char **argv) {
int option_index = 0; int option_index = 0;
int c = getopt_long(argc, argv, "M:Oab:c:d:gm:np:r:hH:vst:uw:W:", int c = getopt_long(argc, argv, "M:Oab:c:d:gm:np:r:hH:vst:uw:W:",
long_options, &option_index); long_options, &option_index);
char *end;
if (c == -1) { if (c == -1) {
break; break;
} }
...@@ -2450,8 +2452,8 @@ int main(int argc, char **argv) { ...@@ -2450,8 +2452,8 @@ int main(int argc, char **argv) {
break; break;
case 'c': case 'c':
errno = 0; errno = 0;
config.header_table_size = strtol(optarg, &end, 10); config.header_table_size = util::parse_uint_with_unit(optarg);
if (errno == ERANGE || *end != '\0') { if (config.header_table_size == -1) {
std::cerr << "-c: Bad option value: " << optarg << std::endl; std::cerr << "-c: Bad option value: " << optarg << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
......
...@@ -138,7 +138,10 @@ Options: ...@@ -138,7 +138,10 @@ Options:
Start sending response when request HEADERS is received, Start sending response when request HEADERS is received,
rather than complete request is received. rather than complete request is received.
--version Display version information and exit. --version Display version information and exit.
-h, --help Display this help and exit.)" << std::endl; -h, --help Display this help and exit.
The <SIZE> argument is an integer and an optional unit (e.g., 10K is
10 * 1024). Units are K, M and G (powers of 1024).)" << std::endl;
} }
} // namespace } // namespace
...@@ -208,8 +211,8 @@ int main(int argc, char **argv) { ...@@ -208,8 +211,8 @@ int main(int argc, char **argv) {
break; break;
case 'c': case 'c':
errno = 0; errno = 0;
config.header_table_size = strtol(optarg, &end, 10); config.header_table_size = util::parse_uint_with_unit(optarg);
if (errno == ERANGE || *end != '\0') { if (config.header_table_size == -1) {
std::cerr << "-c: Bad option value: " << optarg << std::endl; std::cerr << "-c: Bad option value: " << optarg << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment