summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-09-19 21:51:42 +0200
committerLars-Dominik Braun <lars@6xq.net>2011-11-09 20:10:04 +0100
commit2ff8838c97391249b5a44f3cfbdd2416af24517e (patch)
tree1d47375b4a2bb007f762f57a6a1322e4b49905b8
parentc6662b2a1f64536047ea08b329fc115883cac3c2 (diff)
downloadpianobar-windows-2ff8838c97391249b5a44f3cfbdd2416af24517e.tar.gz
pianobar-windows-2ff8838c97391249b5a44f3cfbdd2416af24517e.tar.bz2
pianobar-windows-2ff8838c97391249b5a44f3cfbdd2416af24517e.zip
waitress: merge remaining buffer push into loop
-rw-r--r--src/libwaitress/waitress.c33
1 files changed, 8 insertions, 25 deletions
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: