From 446a19222c59da2b0c92c3f0e686b68e527d8b8e Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 12 Dec 1999 18:12:28 +0000 Subject: [PATCH] * get http request: clear hold buffer before starting to read in HTTP request. This was causing some requests to get corrupted. --- webcit/ChangeLog | 5 ++++- webcit/context_loop.c | 7 ++++++- webcit/webcit.c | 1 + webcit/webserver.c | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 3202f9506..f05a62311 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 1.120 1999/12/12 18:12:28 ajc +* get http request: clear hold buffer before starting to read in HTTP request. + This was causing some requests to get corrupted. + Revision 1.119 1999/12/08 18:25:21 ajc * Increased the size of the backlog queue length passed to accept() and made it a configuration parameter in webcit.h @@ -357,4 +361,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/context_loop.c b/webcit/context_loop.c index aeccf66f5..c40cee998 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -129,6 +129,7 @@ int req_gets(int sock, char *buf, char *hold) int a; if (strlen(hold) == 0) { + strcpy(buf, ""); a = client_gets(sock, buf); if (a<1) return(-1); } else { @@ -213,8 +214,13 @@ void context_loop(int sock) /* * Find out what it is that the web browser is asking for */ + memset(hold, 0, sizeof(hold)); do { if (req_gets(sock, buf, hold) < 0) return; + fprintf(stderr, "%sReq: %s%s\n", + ( (req==NULL) ? "\033[32m" : "" ) , + buf, + ( (req==NULL) ? "\033[0m" : "" ) ); if (!strncasecmp(buf, "Cookie: webcit=", 15)) { cookie_to_stuff(&buf[15], &desired_session, NULL, NULL, NULL); @@ -307,7 +313,6 @@ void context_loop(int sock) pthread_setspecific(MyConKey, (void *)TheSession); TheSession->http_sock = sock; TheSession->lastreq = time(NULL); /* log */ - fprintf(stderr, "%s\n", req->line); session_loop(req); /* perform the requested transaction */ pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */ diff --git a/webcit/webcit.c b/webcit/webcit.c index b98374e26..bbf986c3d 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -620,6 +620,7 @@ void session_loop(struct httprequest *req) } if (ContentLength > 0) { + fprintf(stderr, "Content length: %d\n", ContentLength); content = malloc(ContentLength + 1); read(WC->http_sock, content, ContentLength); diff --git a/webcit/webserver.c b/webcit/webserver.c index 4a4784124..ff4679744 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -170,7 +170,7 @@ int client_gets(int sock, char *buf) retval = client_read(sock, &buf[i], 1); /* - * Strip any trailing not-printable characters. + * Strip any trailing non-printable characters. */ buf[i] = 0; while ((strlen(buf) > 0) && (!isprint(buf[strlen(buf) - 1]))) { -- 2.30.2