From 2ff8838c97391249b5a44f3cfbdd2416af24517e Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 19 Sep 2011 21:51:42 +0200 Subject: waitress: merge remaining buffer push into loop --- src/libwaitress/waitress.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c index 1099252..8202a38 100644 --- a/src/libwaitress/waitress.c +++ b/src/libwaitress/waitress.c @@ -859,11 +859,11 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { bufFilled -= (thisLine-buf); } /* end while hdrParseMode */ - /* push remaining bytes */ - if (bufFilled > 0) { + recvSize = bufFilled; + do { /* data must be \0-terminated for chunked handler */ - buf[bufFilled] = '\0'; - switch (waith->request.dataHandler (waith, buf, bufFilled)) { + buf[recvSize] = '\0'; + switch (waith->request.dataHandler (waith, buf, recvSize)) { case WAITRESS_HANDLER_DONE: FINISH (WAITRESS_RET_OK); break; @@ -875,29 +875,12 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { case WAITRESS_HANDLER_ABORTED: FINISH (WAITRESS_RET_CB_ABORT); break; - } - } - - /* receive content */ - do { - READ_RET (buf, WAITRESS_BUFFER_SIZE-1, &recvSize); - buf[recvSize] = '\0'; - if (recvSize > 0) { - /* FIXME: Copy&waste */ - switch (waith->request.dataHandler (waith, buf, recvSize)) { - case WAITRESS_HANDLER_DONE: - FINISH (WAITRESS_RET_OK); - break; - - case WAITRESS_HANDLER_ERR: - FINISH (WAITRESS_RET_DECODING_ERR); - break; - case WAITRESS_HANDLER_ABORTED: - FINISH (WAITRESS_RET_CB_ABORT); - break; - } + case WAITRESS_HANDLER_CONTINUE: + /* go on */ + break; } + READ_RET (buf, WAITRESS_BUFFER_SIZE-1, &recvSize); } while (recvSize > 0); finish: -- cgit v1.2.3