|
@@ -295,7 +295,7 @@ PUBLIC void websClose()
|
|
Webs *wp;
|
|
Webs *wp;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
-printf("%s %d ---> websClose()\n", __FILE__, __LINE__);
|
|
|
|
|
|
+//printf("%s %d ---> websClose()\n", __FILE__, __LINE__);
|
|
websCloseRoute();
|
|
websCloseRoute();
|
|
#if ME_GOAHEAD_AUTH
|
|
#if ME_GOAHEAD_AUTH
|
|
websCloseAuth();
|
|
websCloseAuth();
|
|
@@ -593,10 +593,10 @@ static int complete(Webs *wp, int reuse)
|
|
if (reuse && wp->flags & WEBS_KEEP_ALIVE && wp->rxRemaining == 0) {
|
|
if (reuse && wp->flags & WEBS_KEEP_ALIVE && wp->rxRemaining == 0) {
|
|
reuseConn(wp);
|
|
reuseConn(wp);
|
|
socketCreateHandler(wp->sid, SOCKET_READABLE, socketEvent, wp);
|
|
socketCreateHandler(wp->sid, SOCKET_READABLE, socketEvent, wp);
|
|
- printf( "Keep connection alive");
|
|
|
|
|
|
+ //printf( "Keep connection alive");
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
- printf("Close connection");
|
|
|
|
|
|
+ //printf("Close connection");
|
|
wp->state = WEBS_BEGIN;
|
|
wp->state = WEBS_BEGIN;
|
|
wp->flags |= WEBS_CLOSED;
|
|
wp->flags |= WEBS_CLOSED;
|
|
return 0;
|
|
return 0;
|
|
@@ -635,7 +635,7 @@ PUBLIC int websListen(char *endpoint)
|
|
} else {
|
|
} else {
|
|
ipaddr = "*";
|
|
ipaddr = "*";
|
|
}
|
|
}
|
|
- printf("Started %s://%s:%d", secure ? "https" : "http", ipaddr, port);
|
|
|
|
|
|
+ //printf("Started %s://%s:%d", secure ? "https" : "http", ipaddr, port);
|
|
|
|
|
|
if (!websHostUrl) {
|
|
if (!websHostUrl) {
|
|
if (port == 80) {
|
|
if (port == 80) {
|
|
@@ -707,12 +707,12 @@ PUBLIC int websAccept(int sid, char *ipaddr, int port, int listenSid)
|
|
Arrange for socketEvent to be called when read data is available
|
|
Arrange for socketEvent to be called when read data is available
|
|
*/
|
|
*/
|
|
lp = socketPtr(listenSid);
|
|
lp = socketPtr(listenSid);
|
|
- printf( "New connection from %s:%d to %s:%d", ipaddr, port, wp->ifaddr, lp->port);
|
|
|
|
|
|
+ //printf( "New connection from %s:%d to %s:%d", ipaddr, port, wp->ifaddr, lp->port);
|
|
|
|
|
|
#if ME_COM_SSL
|
|
#if ME_COM_SSL
|
|
if (lp->secure) {
|
|
if (lp->secure) {
|
|
wp->flags |= WEBS_SECURE;
|
|
wp->flags |= WEBS_SECURE;
|
|
- printf( "Upgrade connection to TLS");
|
|
|
|
|
|
+ //printf( "Upgrade connection to TLS");
|
|
if (sslUpgrade(wp) < 0) {
|
|
if (sslUpgrade(wp) < 0) {
|
|
error("Cannot upgrade to TLS");
|
|
error("Cannot upgrade to TLS");
|
|
return -1;
|
|
return -1;
|
|
@@ -896,10 +896,10 @@ static bool parseIncoming(Webs *wp)
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
- printf("\n<<< Request\n");
|
|
|
|
|
|
+ //printf("\n<<< Request\n");
|
|
c = *end;
|
|
c = *end;
|
|
*end = '\0';
|
|
*end = '\0';
|
|
- printf( "%s\n", wp->rxbuf.servp);
|
|
|
|
|
|
+ //printf( "%s\n", wp->rxbuf.servp);
|
|
*end = c;
|
|
*end = c;
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -980,9 +980,9 @@ static void parseFirstLine(Webs *wp)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
protoVer = getToken(wp, "\r\n");
|
|
protoVer = getToken(wp, "\r\n");
|
|
- if (websGetLogLevel() == 2) {
|
|
|
|
- printf("%s %s %s", wp->method, url, protoVer);
|
|
|
|
- }
|
|
|
|
|
|
+ // if (websGetLogLevel() == 2) {
|
|
|
|
+ // printf("===> %s %s %s", wp->method, url, protoVer);
|
|
|
|
+ // }
|
|
|
|
|
|
/*
|
|
/*
|
|
Parse the URL and store all the various URL components. websUrlParse returns an allocated buffer in buf which we
|
|
Parse the URL and store all the various URL components. websUrlParse returns an allocated buffer in buf which we
|
|
@@ -1333,7 +1333,7 @@ static bool filterChunkData(Webs *wp)
|
|
nbytes = min(bufRoom(&wp->input), len);
|
|
nbytes = min(bufRoom(&wp->input), len);
|
|
// printf("---> bufPutBlk2 len = %d\n", len);
|
|
// printf("---> bufPutBlk2 len = %d\n", len);
|
|
if (len > 0 && (nbytes = bufPutBlk(&wp->input, rxbuf->servp, nbytes)) == 0) {
|
|
if (len > 0 && (nbytes = bufPutBlk(&wp->input, rxbuf->servp, nbytes)) == 0) {
|
|
- printf("<<<<<<<<<<<<<<>>42222>>>>>>>>>>>>\n" );
|
|
|
|
|
|
+ //printf("<<<<<<<<<<<<<<>>42222>>>>>>>>>>>>\n" );
|
|
websError(wp, HTTP_CODE_REQUEST_TOO_LARGE | WEBS_CLOSE, "Too big");
|
|
websError(wp, HTTP_CODE_REQUEST_TOO_LARGE | WEBS_CLOSE, "Too big");
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
@@ -1652,7 +1652,7 @@ PUBLIC void websRedirect(Webs *wp, char *uri)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- printf("---> originalPort: %d, hostbuf: %s\n", originalPort, hostbuf);
|
|
|
|
|
|
+ //printf("---> originalPort: %d, hostbuf: %s\n", originalPort, hostbuf);
|
|
if (smatch(uri, "http://") || smatch(uri, "https://")) {
|
|
if (smatch(uri, "http://") || smatch(uri, "https://")) {
|
|
/* Protocol switch with existing Uri */
|
|
/* Protocol switch with existing Uri */
|
|
scheme = sncmp(uri, "https", 5) == 0 ? "https" : "http";
|
|
scheme = sncmp(uri, "https", 5) == 0 ? "https" : "http";
|
|
@@ -1796,7 +1796,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
|
|
|
|
|
|
if (!(wp->flags & WEBS_RESPONSE_TRACED)) {
|
|
if (!(wp->flags & WEBS_RESPONSE_TRACED)) {
|
|
wp->flags |= WEBS_RESPONSE_TRACED;
|
|
wp->flags |= WEBS_RESPONSE_TRACED;
|
|
- printf( "\n>>> Response\n");
|
|
|
|
|
|
+// printf( "\n>>> Response\n");
|
|
}
|
|
}
|
|
if (key) {
|
|
if (key) {
|
|
if (websWriteBlock(wp, key, strlen(key)) < 0) {
|
|
if (websWriteBlock(wp, key, strlen(key)) < 0) {
|
|
@@ -1805,7 +1805,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
|
|
if (websWriteBlock(wp, ": ", 2) < 0) {
|
|
if (websWriteBlock(wp, ": ", 2) < 0) {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- printf("%s: ", key);
|
|
|
|
|
|
+ //printf("===> %s: ", key);
|
|
}
|
|
}
|
|
if (fmt) {
|
|
if (fmt) {
|
|
va_start(vargs, fmt);
|
|
va_start(vargs, fmt);
|
|
@@ -1815,7 +1815,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
|
|
}
|
|
}
|
|
va_end(vargs);
|
|
va_end(vargs);
|
|
assert(strstr(buf, "UNION") == 0);
|
|
assert(strstr(buf, "UNION") == 0);
|
|
- printf("%s", buf);
|
|
|
|
|
|
+ //printf("===> %s", buf);
|
|
if (websWriteBlock(wp, buf, strlen(buf)) < 0) {
|
|
if (websWriteBlock(wp, buf, strlen(buf)) < 0) {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -1824,7 +1824,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- printf("\r\n");
|
|
|
|
|
|
+ //printf("\r\n");
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2079,15 +2079,15 @@ PUBLIC int websFlush(Webs *wp, bool block)
|
|
}
|
|
}
|
|
op = &wp->output;
|
|
op = &wp->output;
|
|
if (wp->flags & WEBS_CHUNKING) {
|
|
if (wp->flags & WEBS_CHUNKING) {
|
|
- printf("websFlush chunking finalized %d", wp->finalized);
|
|
|
|
|
|
+ //printf("websFlush chunking finalized %d", wp->finalized);
|
|
if (flushChunkData(wp) && wp->finalized) {
|
|
if (flushChunkData(wp) && wp->finalized) {
|
|
- printf("websFlush: write chunk trailer");
|
|
|
|
|
|
+ //printf("websFlush: write chunk trailer");
|
|
bufPutStr(op, "\r\n0\r\n\r\n");
|
|
bufPutStr(op, "\r\n0\r\n\r\n");
|
|
bufAddNull(op);
|
|
bufAddNull(op);
|
|
wp->flags &= ~WEBS_CHUNKING;
|
|
wp->flags &= ~WEBS_CHUNKING;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- printf( "websFlush: buflen %d", bufLen(op));
|
|
|
|
|
|
+// printf( "websFlush: buflen %d", bufLen(op));
|
|
written = 0;
|
|
written = 0;
|
|
while ((nbytes = bufLen(op)) > 0) {
|
|
while ((nbytes = bufLen(op)) > 0) {
|
|
if ((written = websWriteSocket(wp, op->servp, nbytes)) < 0) {
|
|
if ((written = websWriteSocket(wp, op->servp, nbytes)) < 0) {
|
|
@@ -2107,7 +2107,7 @@ PUBLIC int websFlush(Webs *wp, bool block)
|
|
} else if (written == 0) {
|
|
} else if (written == 0) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- printf( "websFlush: wrote %d to socket", written);
|
|
|
|
|
|
+ //printf( "websFlush: wrote %d to socket", written);
|
|
bufAdjustStart(op, written);
|
|
bufAdjustStart(op, written);
|
|
bufCompact(op);
|
|
bufCompact(op);
|
|
nbytes = bufLen(op);
|
|
nbytes = bufLen(op);
|
|
@@ -3217,9 +3217,9 @@ static void pruneSessions()
|
|
freeSession(sp);
|
|
freeSession(sp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (oldCount != sessionCount || sessionCount) {
|
|
|
|
- printf("Prune %d sessions. Remaining: %d", oldCount - sessionCount, sessionCount);
|
|
|
|
- }
|
|
|
|
|
|
+ // if (oldCount != sessionCount || sessionCount) {
|
|
|
|
+ // printf("Prune %d sessions. Remaining: %d", oldCount - sessionCount, sessionCount);
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
websRestartEvent(pruneId, WEBS_SESSION_PRUNE);
|
|
websRestartEvent(pruneId, WEBS_SESSION_PRUNE);
|
|
}
|
|
}
|
|
@@ -3299,7 +3299,7 @@ static void setFileLimits()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
getrlimit(RLIMIT_NOFILE, &r);
|
|
getrlimit(RLIMIT_NOFILE, &r);
|
|
- printf("Max files soft %d, max %d", (int)r.rlim_cur, (int)r.rlim_max);
|
|
|
|
|
|
+ //printf("Max files soft %d, max %d", (int)r.rlim_cur, (int)r.rlim_max);
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|