Hi,

I have made a patch which solves a problem I had last week--isapi_redirector
sometimes corrupted data sent by the client.

I'm not sure where to send the patch, I hope I don't abuse this list by
submitting it here.

Someone more intimate with the code might want to make a better patch, the
code that follows solves the problem but is not very elegant. I have added
code that makes sure the content_length field in jk_ws_service_t gets
updated for each call to jk2_service_iis_read.

I have used version 2.0.2 of JK2.

Joakim Strom
Excosoft
===================

int jk2_requtil_readFully(jk_env_t *env, jk_ws_service_t *s,
                         unsigned char *buf,
                         unsigned  len)
{
    unsigned rdlen = 0;
    unsigned padded_len = len;
    long content_read = s->content_read; // Patch Dec 9, 2002. Save value to restore 
later

    if (s->is_chunked && s->no_more_chunks) {
        return 0;
    }
    if (s->is_chunked) {
        /* Corner case: buf must be large enough to hold next
         * chunk size (if we're on or near a chunk border).
         * Pad the length to a reasonable value, otherwise the
         * read fails and the remaining chunks are tossed.
         */
        padded_len = (len < CHUNK_BUFFER_PAD) ?
            len : len - CHUNK_BUFFER_PAD;
    }

    while(rdlen < padded_len) {
        unsigned this_time = 0;
        if(s->read(env, s, buf + rdlen, len - rdlen, &this_time)) {
            return -1;
        }
        s->content_read += this_time; // Patch Dec 9, 2002.
                                      // Make sure content_read gets incremented
                                      // if this loop runs more than once

        if(0 == this_time) {
            if (s->is_chunked) {
                s->no_more_chunks = 1; /* read no more */
            }
            break;
        }
        rdlen += this_time;
    }
    s->content_read = content_read; // Patch Dec 9, 2002. Reset the value before 
returning

    return (int)rdlen;
}



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to