* get http request: clear hold buffer before starting to read in HTTP request.
authorArt Cancro <ajc@citadel.org>
Sun, 12 Dec 1999 18:12:28 +0000 (18:12 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 12 Dec 1999 18:12:28 +0000 (18:12 +0000)
  This was causing some requests to get corrupted.

webcit/ChangeLog
webcit/context_loop.c
webcit/webcit.c
webcit/webserver.c

index 3202f950625764ea92680133a66b1d23d944fcaa..f05a623112c6c88c9dfe2fa963820b26dbaf5dde 100644 (file)
@@ -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 <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index aeccf66f54500548efcd77db698a20ce5d3f13d4..c40cee99806715925f64835f2f01cdcccc98e7b9 100644 (file)
@@ -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 */
 
index b98374e26863a74a86e8ce8cecbfbbe23733023c..bbf986c3de7c4d27b40ee1462c8d349fc794e92a 100644 (file)
@@ -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);
 
index 4a478412449e2a0a03eddf7e5390d75372be7fb9..ff4679744ad815c29e26dda11721fe7d5f3f42a7 100644 (file)
@@ -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]))) {