Compare commits
No commits in common. "fcad98059315f908ff1b69e416ec3661a098bb44" and "c9c21105f63e4ed385a38c6d39dae657d4535316" have entirely different histories.
fcad980593
...
c9c21105f6
4 changed files with 7 additions and 19 deletions
|
@ -7,7 +7,6 @@ A simple HTTP/1.1 server written in C.
|
|||
Usage:
|
||||
-p <port> | --port <port>
|
||||
--config=<config_file>
|
||||
--disable-peer-addr-print
|
||||
|
||||
## Before Compiling
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ void print_usage(void) {
|
|||
puts("Usage:");
|
||||
puts(" -p <port> | --port <port>");
|
||||
puts(" --config=<config_file>");
|
||||
puts(" --disable-peer-addr-print");
|
||||
}
|
||||
|
||||
Args parse_args(int argc, char **argv) {
|
||||
|
@ -46,8 +45,6 @@ Args parse_args(int argc, char **argv) {
|
|||
++argv;
|
||||
} else if (strncmp(argv[0], "--config=", 9) == 0 && strlen(argv[0]) > 9) {
|
||||
args.config_file = argv[0] + 9;
|
||||
} else if (strcmp(argv[0], "--disable-peer-addr-print") == 0) {
|
||||
args.flags |= 1;
|
||||
} else {
|
||||
puts("ERROR: Invalid args!\n");
|
||||
print_usage();
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#define SEODISPARATE_COM_C_SIMPLE_HTTP_ARG_PARSE_H_
|
||||
|
||||
typedef struct Args {
|
||||
// xxxx xxx0 - enable peer addr print.
|
||||
// xxxx xxx1 - disable peer addr print.
|
||||
unsigned short flags;
|
||||
unsigned short port;
|
||||
// Does not need to be free'd, this should point to a string in argv.
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const Args args = parse_args(argc, argv);
|
||||
Args args = parse_args(argc, argv);
|
||||
|
||||
if (!args.config_file) {
|
||||
fprintf(stderr, "ERROR Config file not specified!\n");
|
||||
|
@ -110,7 +110,6 @@ int main(int argc, char **argv) {
|
|||
printf("WARNING: accept: errno %d\n", errno);
|
||||
} else if (ret >= 0) {
|
||||
// Received connection, handle it.
|
||||
if ((args.flags & 1) == 0) {
|
||||
printf("Peer connected: addr is ");
|
||||
for (unsigned int idx = 0; idx < 16; ++idx) {
|
||||
if (idx % 2 == 0 && idx > 0) {
|
||||
|
@ -119,9 +118,6 @@ int main(int argc, char **argv) {
|
|||
printf("%02x", peer_info.sin6_addr.s6_addr[idx]);
|
||||
}
|
||||
puts("");
|
||||
} else {
|
||||
printf("Peer connected.\n");
|
||||
}
|
||||
int connection_fd = ret;
|
||||
read_ret = read(connection_fd, recv_buf, C_SIMPLE_HTTP_RECV_BUF_SIZE);
|
||||
if (read_ret < 0) {
|
||||
|
@ -132,7 +128,6 @@ int main(int argc, char **argv) {
|
|||
continue;
|
||||
}
|
||||
// DEBUG print received buf.
|
||||
#ifndef NDEBUG
|
||||
for (unsigned int idx = 0;
|
||||
idx < C_SIMPLE_HTTP_RECV_BUF_SIZE && idx < read_ret;
|
||||
++idx) {
|
||||
|
@ -144,7 +139,6 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
size_t response_size = 0;
|
||||
enum C_SIMPLE_HTTP_ResponseCode response_code;
|
||||
|
|
Loading…
Reference in a new issue