diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-10-06 10:28:31 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-10-06 10:28:31 +0000 |
commit | b443e80b51a92c77d27f14ac8cfb9bde7dd7ede2 (patch) | |
tree | 5feed0002e03723f4ecabcea779153988fd6914f /tools | |
parent | f01b4c00f277c6a004726496bed19a5cfe6869f5 (diff) | |
download | FreeBSD-src-b443e80b51a92c77d27f14ac8cfb9bde7dd7ede2.zip FreeBSD-src-b443e80b51a92c77d27f14ac8cfb9bde7dd7ede2.tar.gz |
Improve realism of benchmark httpd: return some HTTP headers as part
of the sendfile() system call.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/netrate/httpd/httpd.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tools/tools/netrate/httpd/httpd.c b/tools/tools/netrate/httpd/httpd.c index d8907ff..549fe4a 100644 --- a/tools/tools/netrate/httpd/httpd.c +++ b/tools/tools/netrate/httpd/httpd.c @@ -28,6 +28,7 @@ #include <sys/types.h> #include <sys/socket.h> +#include <sys/uio.h> #include <netinet/in.h> @@ -48,6 +49,11 @@ #define BUFFER (48*1024) #define HTTP 8000 +#define HTTP_OK "HTTP/1.1 200 OK\n" +#define HTTP_SERVER "Server rwatson_httpd/1.0 (FreeBSD)\n" +#define HTTP_CONNECTION "Connection: close\n" +#define HTTP_CONTENT "Content-Type: text/html\n" + static const char *path; static int listen_sock; static int data_file; @@ -58,6 +64,8 @@ static int data_file; static int http_serve(int sock) { + struct iovec header_iovec[4]; + struct sf_hdtr sf_hdtr; ssize_t len; int ncount; char ch; @@ -78,7 +86,22 @@ http_serve(int sock) break; } - if (sendfile(data_file, sock, 0, 0, NULL, NULL, 0) < 0) + bzero(&sf_hdtr, sizeof(sf_hdtr)); + bzero(&header_iovec, sizeof(header_iovec)); + header_iovec[0].iov_base = HTTP_OK; + header_iovec[0].iov_len = strlen(HTTP_OK); + header_iovec[1].iov_base = HTTP_SERVER; + header_iovec[1].iov_len = strlen(HTTP_SERVER); + header_iovec[2].iov_base = HTTP_CONNECTION; + header_iovec[2].iov_len = strlen(HTTP_CONNECTION); + header_iovec[3].iov_base = HTTP_CONTENT; + header_iovec[3].iov_len = strlen(HTTP_CONTENT); + sf_hdtr.headers = header_iovec; + sf_hdtr.hdr_cnt = 4; + sf_hdtr.trailers = NULL; + sf_hdtr.trl_cnt = 0; + + if (sendfile(data_file, sock, 0, 0, &sf_hdtr, NULL, 0) < 0) warn("sendfile"); return (0); |