Listing 1. Fragments of the Functions clientWriteComplete() and
clientReadRequest() from the src/client_side.c File

static void
clientWriteComplete(int fd,
                    char *bufnotused,
                    size_t size,
                    int errflag,
                    void *data)
{
    clientHttpRequest *http = data;

...

    if (size > 0)
    {
        kb_incr(&statCounter.client_http.kbytes_out,
                size);
/*-Here comes the SB section----------------------*/
#ifdef SB_INCLUDE
    if (http->request->auth_user_request)
    {
        if ( authenticateUserRequestUsername(
             http->request->auth_user_request) )
            if (!clientdbUpdate_sb(
                authenticateUserRequestUsername(
                    http->request->auth_user_request),
                    size) )
            {
                comm_close(fd);
                return;
            }
    }
#endif
/*------------------------------------------------*/
    if (isTcpHit(http->log_type))
        kb_incr(
            &statCounter.client_http.hit_kbytes_out,
            size);
    }

...

}

...

static void
clientReadRequest(int fd, void *data)
{
    ConnStateData *conn = data;
    int parser_return_code = 0;
    request_t *request = NULL;
    int size;
    void *p;
    method_t method;
    clientHttpRequest *http = NULL;
    clientHttpRequest **H = NULL;
    char *prefix = NULL;
    ErrorState *err = NULL;
    fde *F = &fd_table[fd];
    int len = conn->in.size - conn->in.offset - 1;

...

    /* Process request body if any */
    if (conn->in.offset > 0 &&
        conn->body.callback != NULL)
    {
        clientProcessBody(conn);
    }
    /* Process next request */
    while (conn->in.offset > 0 &&
           conn->body.size_left == 0)
    {
        int nrequests;
        size_t req_line_sz;

...

        /* Process request */
        http = parseHttpRequest(conn,
            &method,
            &parser_return_code,
            &prefix,
            &req_line_sz);
        if (!http)
            safe_free(prefix);
        if (http) {

...

        if (request->method == METHOD_CONNECT)
            {
            /* Stop reading requests... */
                commSetSelect(fd,
                COMM_SELECT_READ,
                NULL,
                NULL,
                0);
                clientAccessCheck(http);
/*-Here comes the SB section----------------------*/
#ifdef SB_INCLUDE
            if(http->request->auth_user_request)
            {
                if (
                authenticateUserRequestUsername(
                http->request->auth_user_request
                )!=NULL)
                {
                    if(!clientdbCount_sb(
                        authenticateUserRequestUsername(
                        http->request->
                            auth_user_request)))
                        {
                            comm_close(fd);
                            return;
                        }
                    }
                }
#endif
/*------------------------------------------------*/
            break;
            } else {
            clientAccessCheck(http);
/*-Here comes the SB section----------------------*/
#ifdef SB_INCLUDE
            if(http->request->auth_user_request)
            {
                if (
                    authenticateUserRequestUsername(
                    http->request->auth_user_request
                    )!=NULL)
                {
                    if(!clientdbCount_sb(
                    authenticateUserRequestUsername(
                    http->request->auth_user_request)))
                    {
                        comm_close(fd);
                        return;
                    }
                }
            }
#endif
/*------------------------------------------------*/

/* while offset > 0 && body.size_left == 0 */
                continue;
            }
        } else if (parser_return_code == 0) {

...

/* while offset > 0 && conn->body.size_left == 0 */
    }

...

}