httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/modules/proxy proxy_ajp.c
Date Wed, 11 Aug 2004 20:42:00 GMT
wrowe       2004/08/11 13:42:00

  Modified:    modules/proxy proxy_ajp.c
  Log:
  Add the logic to read the body.
  
  Submitted by: jfclere
  
  Revision  Changes    Path
  1.3       +58 -29    httpd-2.0/modules/proxy/proxy_ajp.c
  
  Index: proxy_ajp.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_ajp.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- proxy_ajp.c	11 Aug 2004 20:41:23 -0000	1.2
  +++ proxy_ajp.c	11 Aug 2004 20:42:00 -0000	1.3
  @@ -68,7 +68,7 @@
       def_port = apr_uri_port_of_scheme(scheme);
   
       ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  -             "proxy: HTTP: canonicalising URL %s", url);
  +             "proxy: AJP: canonicalising URL %s", url);
   
       /* do syntatic check.
        * We break the URL into host, port, path, search
  @@ -113,30 +113,6 @@
       return OK;
   }
    
  -/* Clear all connection-based headers from the incoming headers table */
  -static void ap_proxy_clear_connection(apr_pool_t *p, apr_table_t *headers)
  -{
  -    const char *name;
  -    char *next = apr_pstrdup(p, apr_table_get(headers, "Connection"));
  -
  -    apr_table_unset(headers, "Proxy-Connection");
  -    if (!next)
  -        return;
  -
  -    while (*next) {
  -        name = next;
  -        while (*next && !apr_isspace(*next) && (*next != ',')) {
  -            ++next;
  -        }
  -        while (*next && (apr_isspace(*next) || (*next == ','))) {
  -            *next = '\0';
  -            ++next;
  -        }
  -        apr_table_unset(headers, name);
  -    }
  -    apr_table_unset(headers, "Connection");
  -}
  -
   static
   apr_status_t ap_proxy_http_determine_connection(apr_pool_t *p, request_rec *r,
                                                   proxy_ajp_conn_t *p_conn,
  @@ -166,7 +142,7 @@
       }
   
       ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  -                 "proxy: HTTP connecting %s to %s:%d", *url, uri->hostname,
  +                 "proxy: AJP connecting %s to %s:%d", *url, uri->hostname,
                    uri->port);
   
       /* do a DNS lookup for the destination host */
  @@ -282,7 +258,7 @@
           apr_socket_timeout_set(p_conn->sock, current_timeout);
           if ( APR_STATUS_IS_EOF(socket_status) ) {
               ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
  -                         "proxy: HTTP: previous connection is closed");
  +                         "proxy: AJP: previous connection is closed");
               new = 1;
           }
       }
  @@ -368,6 +344,7 @@
   {
       apr_status_t status;
       int result;
  +    apr_bucket_brigade *input_brigade;
   
       /*
        * Send the AJP request to the remote server
  @@ -382,8 +359,60 @@
           return status;
       }
   
  +    /* read the first bloc of data */
  +    input_brigade = apr_brigade_create(p, r->connection->bucket_alloc);
  +    status = ap_get_brigade(r->input_filters, input_brigade,
  +                            AP_MODE_READBYTES, APR_BLOCK_READ,
  +                            8186);
  + 
  +    if (status != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  +                     "proxy: ap_get_brigade failed");
  +        apr_brigade_destroy(input_brigade);
  +        return status;
  +    }
  +
  +    /* have something */
  +    if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(input_brigade))) {
  +        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  +                     "proxy: APR_BUCKET_IS_EOS");
  +    }
  +
  +    if (1) { /* XXXX only when something to send ? */
  +        void *msg;
  +        apr_size_t bufsiz;
  +        char *buff;
  +        long len;
  +        status = ajp_alloc_data_msg(r, &buff, &bufsiz, &msg);
  +        if (status != APR_SUCCESS) {
  +            return status;
  +        }
  +        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  +                     "proxy: data to read (max %d at %08x)", bufsiz, buff);
  +
  +        /* XXXX calls apr_brigade_flatten... */
  +        status = apr_brigade_flatten(input_brigade, buff, &bufsiz);
  +        if (status != APR_SUCCESS) {
  +             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  +                     "proxy: apr_brigade_flatten");
  +            return status;
  +        }
  +
  +        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
  +                     "proxy: got %d byte of data", bufsiz);
  +        if (bufsiz > 0) {
  +            status = ajp_send_data_msg(p_conn->sock, r, msg, bufsiz);
  +            if (status != APR_SUCCESS) {
  +                ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
  +                             "proxy: request failed to %pI (%s)",
  +                             p_conn->addr, p_conn->name);
  +                return status;
  +            }
  +        }
  +    }
  +
       /* read the response */
  -    status = ajp_read_header(p_conn->sock,r,&(p_conn->data));
  +    status = ajp_read_header(p_conn->sock, r, &(p_conn->data));
       if (status != APR_SUCCESS) {
           ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
                        "proxy: request failed to %pI (%s)",
  @@ -400,7 +429,7 @@
           return APR_SUCCESS;
       }
   
  -    /* send data via brigade or not??? */
  +    /* XXXX: need logic to send the rest of the data */
   /*
       status = ajp_send_data(p_conn->sock,r);
       if (status != APR_SUCCESS) {
  
  
  

Mime
View raw message