From 87b4d04dc18a4e13db37ed07d8222992b52fab1a Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 18 Sep 2011 17:40:34 +0200 Subject: waitress: added identity handler --- src/libwaitress/waitress.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c index 0c52f06..00b775b 100644 --- a/src/libwaitress/waitress.c +++ b/src/libwaitress/waitress.c @@ -507,6 +507,14 @@ static void WaitressHandleHeader (WaitressHandle_t *waith, const char * const ke } } +/* identity encoding handler + */ +static WaitressCbReturn_t WaitressHandleIdentity (WaitressHandle_t *waith, + char *buf, size_t size) { + waith->contentReceived += size; + return waith->callback (buf, size, waith->data); +} + /* Receive data from host and call *callback () * @param waitress handle * @return WaitressReturn_t @@ -705,8 +713,7 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { /* push remaining bytes */ if (bufFilled > 0) { - waith->contentReceived += bufFilled; - if (waith->callback (thisLine, bufFilled, waith->data) == + if (WaitressHandleIdentity (waith, thisLine, bufFilled) == WAITRESS_CB_RET_ERR) { CLOSE_RET (WAITRESS_RET_CB_ABORT); } @@ -716,8 +723,7 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { do { READ_RET (recvBuf, sizeof (recvBuf), &recvSize); if (recvSize > 0) { - waith->contentReceived += recvSize; - if (waith->callback (recvBuf, recvSize, waith->data) == + if (WaitressHandleIdentity (waith, recvBuf, recvSize) == WAITRESS_CB_RET_ERR) { wRet = WAITRESS_RET_CB_ABORT; break; -- cgit v1.2.3