|
@@ -649,6 +649,9 @@ PUBLIC int websListen(cchar *endpoint)
|
|
error("Too many listen endpoints");
|
|
error("Too many listen endpoints");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ printf("socket ++++++++++++++++++>%s\n", endpoint);
|
|
socketParseAddress(endpoint, &ip, &port, &secure, 80);
|
|
socketParseAddress(endpoint, &ip, &port, &secure, 80);
|
|
error("---> ip: %s, port: %d, secure: %d\n", ip, port, secure);
|
|
error("---> ip: %s, port: %d, secure: %d\n", ip, port, secure);
|
|
if ((sid = socketListen(ip, port, websAccept, 0)) < 0) {
|
|
if ((sid = socketListen(ip, port, websAccept, 0)) < 0) {
|
|
@@ -1638,13 +1641,13 @@ PUBLIC void websResponse(Webs *wp, int code, cchar *message)
|
|
websWriteBlock(wp, message, len);
|
|
websWriteBlock(wp, message, len);
|
|
websWriteBlock(wp, "\r\n", 2);
|
|
websWriteBlock(wp, "\r\n", 2);
|
|
|
|
|
|
- // websWrite(wp, message);
|
|
|
|
|
|
+ websWrite(wp, message);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
logmsg(2,"-----------------------response 2-----------------------%s", message);
|
|
logmsg(2,"-----------------------response 2-----------------------%s", message);
|
|
websWriteHeaders(wp, 0, 0);
|
|
websWriteHeaders(wp, 0, 0);
|
|
websWriteEndHeaders(wp);
|
|
websWriteEndHeaders(wp);
|
|
- // websWriteBlock(wp, message, len);
|
|
|
|
|
|
+ websWriteBlock(wp, message, len);
|
|
}
|
|
}
|
|
websDone(wp);
|
|
websDone(wp);
|
|
}
|
|
}
|
|
@@ -1889,7 +1892,6 @@ PUBLIC void websSetStatus(Webs *wp, int code)
|
|
PUBLIC void websWriteHeaders(Webs *wp, ssize length, cchar *location)
|
|
PUBLIC void websWriteHeaders(Webs *wp, ssize length, cchar *location)
|
|
{
|
|
{
|
|
|
|
|
|
- printf("-------------writeHead------0-----------------s\n");
|
|
|
|
WebsKey *cookie, *key, *next;
|
|
WebsKey *cookie, *key, *next;
|
|
char *date, *protoVersion;
|
|
char *date, *protoVersion;
|
|
|
|
|
|
@@ -1985,8 +1987,6 @@ PUBLIC void websSetTxLength(Webs *wp, ssize length)
|
|
*/
|
|
*/
|
|
PUBLIC ssize websWrite(Webs *wp, cchar *fmt, ...)
|
|
PUBLIC ssize websWrite(Webs *wp, cchar *fmt, ...)
|
|
{
|
|
{
|
|
-
|
|
|
|
- printf("-------------writebody------0-----------------s\n" );
|
|
|
|
va_list vargs;
|
|
va_list vargs;
|
|
char *buf;
|
|
char *buf;
|
|
ssize rc;
|
|
ssize rc;
|
|
@@ -2004,7 +2004,6 @@ PUBLIC ssize websWrite(Webs *wp, cchar *fmt, ...)
|
|
va_end(vargs);
|
|
va_end(vargs);
|
|
assert(buf);
|
|
assert(buf);
|
|
if (buf) {
|
|
if (buf) {
|
|
- printf("-------------writebody------1-----------------s\n" );
|
|
|
|
rc = websWriteBlock(wp, buf, strlen(buf));
|
|
rc = websWriteBlock(wp, buf, strlen(buf));
|
|
wfree(buf);
|
|
wfree(buf);
|
|
}
|
|
}
|
|
@@ -2119,7 +2118,6 @@ static bool flushChunkData(Webs *wp)
|
|
PUBLIC int websFlush(Webs *wp, bool block)
|
|
PUBLIC int websFlush(Webs *wp, bool block)
|
|
{
|
|
{
|
|
|
|
|
|
- logmsg(2, "-----------------websFlush--1----------------\n");
|
|
|
|
WebsBuf *op;
|
|
WebsBuf *op;
|
|
ssize nbytes, written;
|
|
ssize nbytes, written;
|
|
int errCode, wasBlocking;
|
|
int errCode, wasBlocking;
|
|
@@ -2137,7 +2135,6 @@ PUBLIC int websFlush(Webs *wp, bool block)
|
|
wp->flags &= ~WEBS_CHUNKING;
|
|
wp->flags &= ~WEBS_CHUNKING;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- logmsg(2, "-----------------websFlush--2----------------\n");
|
|
|
|
trace(6, "websFlush: buflen %d", bufLen(op));
|
|
trace(6, "websFlush: buflen %d", bufLen(op));
|
|
written = 0;
|
|
written = 0;
|
|
while ((nbytes = bufLen(op)) > 0) {
|
|
while ((nbytes = bufLen(op)) > 0) {
|
|
@@ -2163,13 +2160,11 @@ PUBLIC int websFlush(Webs *wp, bool block)
|
|
bufCompact(op);
|
|
bufCompact(op);
|
|
nbytes = bufLen(op);
|
|
nbytes = bufLen(op);
|
|
}
|
|
}
|
|
- logmsg(2, "-----------------websFlush--3----------------\n");
|
|
|
|
assert(websValid(wp));
|
|
assert(websValid(wp));
|
|
|
|
|
|
if (bufLen(op) == 0 && wp->finalized) {
|
|
if (bufLen(op) == 0 && wp->finalized) {
|
|
wp->state = WEBS_COMPLETE;
|
|
wp->state = WEBS_COMPLETE;
|
|
}
|
|
}
|
|
- logmsg(2, "-----------------websFlush--4----------------\n");
|
|
|
|
if (block) {
|
|
if (block) {
|
|
socketSetBlock(wp->sid, wasBlocking);
|
|
socketSetBlock(wp->sid, wasBlocking);
|
|
}
|
|
}
|
|
@@ -2265,6 +2260,7 @@ PUBLIC ssize websWriteBlock(Webs *wp, cchar *buf, ssize size)
|
|
buf += thisWrite;
|
|
buf += thisWrite;
|
|
written += thisWrite;
|
|
written += thisWrite;
|
|
}
|
|
}
|
|
|
|
+
|
|
bufAddNull(op);
|
|
bufAddNull(op);
|
|
if (wp->state >= WEBS_COMPLETE && written == 0) {
|
|
if (wp->state >= WEBS_COMPLETE && written == 0) {
|
|
return -1;
|
|
return -1;
|
|
@@ -2391,7 +2387,7 @@ static void checkTimeout(void *arg, int id)
|
|
|
|
|
|
printf("<<<<<<<<<checkTimeout<<<<websDebug<<<<>>%#x\n", websDebug);
|
|
printf("<<<<<<<<<checkTimeout<<<<websDebug<<<<>>%#x\n", websDebug);
|
|
elapsed = getTimeSinceMark(wp) * 1000;
|
|
elapsed = getTimeSinceMark(wp) * 1000;
|
|
- if (1) {
|
|
|
|
|
|
+ if (websDebug) {
|
|
websRestartEvent(id, (int) WEBS_TIMEOUT);
|
|
websRestartEvent(id, (int) WEBS_TIMEOUT);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -3450,6 +3446,8 @@ PUBLIC int websServer(cchar *endpoint, cchar *documents)
|
|
{
|
|
{
|
|
int finished = 0;
|
|
int finished = 0;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ printf("websServer>>>>>>>>>>>>>>>>>>%s\n", documents);
|
|
if (websOpen(documents, "route.txt") < 0) {
|
|
if (websOpen(documents, "route.txt") < 0) {
|
|
error("Cannot initialize server. Exiting.");
|
|
error("Cannot initialize server. Exiting.");
|
|
return -1;
|
|
return -1;
|