Squid code

From: <develop@dont-contact.us>
Date: Thu, 16 Nov 2000 18:59:01 +0200 (EET)

Hi there,

I have a problem with the code. I need to do this:

        When a request which is not in cache is processing, it sends the
data to client as it reads from server. I need to stop this simultaneous
receive/send method and wait until all data is read from server. Then do a
special processing on the requested html, then send it to the client. I
changed httpReadReply in http.c and it looks like it works fine but it's
not. The main problem is, it processes the document 2 times and don't know
why. Looks like, it processes the document when server reading is done,
and
client sending is done.

Working in 2.2 Stable 5 version and did these changes:

httpReadReply in http.c, there is a if statement like this:

                /*
                 * If its not a reply that we will re-forward, then
                 * allow the client to get it.
                 */
                if (!fwdReforwardableStatus(s)) {
                  EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
                }

I commented out that EBIT_CLR and put that code in this location:

    } else if (len == 0) {
        /* Connection closed; retrieval done. */
        printf( "\033[1m***** Connection closed\033[0m\n" );
        if(
!fwdReforwardableStatus(entry->mem_obj->reply->sline.status) ) {
                {
                mem_hdr *hdr = &(entry->mem_obj->data_hdr);
                mem_node *node = hdr->head;

                printf( "MEMOBJECT (Connection Closed) = {\n" );
                for( ; node ; node = node->next )
                        printf( "%s", node->data );
                printf( "\n}\n" );

                if( entry != NULL && entry->mem_obj != NULL &&
entry->mem_obj->reply != NULL &&
                    entry->mem_obj->reply->content_type.buf != NULL ) {
                        if( !strncasecmp( "text/html",
entry->mem_obj->reply->content_type.buf, 9 ) )
                                ProcessDocument( node );
                }

                }
                EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
        }

and

        } else if (httpPconnTransferDone(httpState)) {
                if(
!fwdReforwardableStatus(entry->mem_obj->reply->sline.status) ) {
                        {
                        mem_hdr *hdr = &(entry->mem_obj->data_hdr);
                        mem_node *node = hdr->head;

                        printf( "******* CONTENT_TYPE is (%s)\n",
entry->mem_obj->reply->content_type.buf );
                        if( entry != NULL && entry->mem_obj != NULL &&
entry->mem_obj->reply != NULL &&
                            entry->mem_obj->reply->content_type.buf !=
NULL
) {
                                if( !strncasecmp( "text/html",
entry->mem_obj->reply->content_type.buf, 9 ) )
                                        ProcessDocument( node );
                        }

                        printf( "MEMOBJECT (Document Done) = {\n" );
                        for( ; node ; node = node->next )
                                printf( "%s", node->data );
                        }
                        printf( "\n}\n" );
                        EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
                }

it made the client wait until all data is finished.

Can you help about this problem? Once a request is made and it's not in
cache, it will be processed by my function and than it will be stored as
it's processed. But only point is, document should be completed before
processing.. I need to do this..

TIA,

Caner
Received on Thu Nov 16 2000 - 09:19:37 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:59 MST