You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2010/11/30 02:43:06 UTC

svn commit: r1040383 [17/38] - in /trafficserver/traffic/branches/wccp: ./ build/ contrib/ contrib/perl/AdminClient/lib/Apache/TS/ example/ example/add-header/ example/app-template/ example/append-transform/ example/basic-auth/ example/blacklist-0/ exa...

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc Tue Nov 30 01:42:55 2010
@@ -186,10 +186,8 @@ update_cache_control_information_from_co
     HttpTransact::does_client_request_permit_storing(&(s->cache_control), &s->hdr_info.client_request);
 
   s->cache_info.directives.does_client_permit_lookup =
-    HttpTransact::does_client_request_permit_cached_response(s->
-                                                             http_config_param,
-                                                             &(s->
-                                                               cache_control),
+    HttpTransact::does_client_request_permit_cached_response(s->http_config_param,
+                                                             &(s->cache_control),
                                                              &s->hdr_info.client_request, s->via_string);
 
   s->cache_info.directives.does_client_permit_dns_storing =
@@ -770,9 +768,15 @@ HttpTransact::perform_accept_encoding_fi
 void
 HttpTransact::StartRemapRequest(State * s)
 {
+  
+  if (s->api_skip_all_remapping) {
+    Debug ("http_trans", "API request to skip remapping");
+    TRANSACT_RETURN(HTTP_POST_REMAP_SKIP, HttpTransact::HandleRequest);
+  }
+  
   Debug("http_trans", "START HttpTransact::StartRemapRequest");
 
-        /**
+  /**
 	 * Check for URL remappings before checking request
 	 * validity or initializing state variables since
 	 * the remappings can insert or change the destination
@@ -788,16 +792,12 @@ HttpTransact::StartRemapRequest(State * 
 
   const char syntxt[] = "synthetic.txt";
 
-  s->cop_test_page =
-    (ptr_len_cmp(host,
-                 host_len,
-                 local_host_ip_str,
-                 sizeof(local_host_ip_str) - 1) == 0) && (ptr_len_cmp(path, path_len, syntxt, sizeof(syntxt) - 1) == 0);
+  s->cop_test_page = (ptr_len_cmp(host, host_len, local_host_ip_str, sizeof(local_host_ip_str) - 1) == 0) &&
+    (ptr_len_cmp(path, path_len, syntxt, sizeof(syntxt) - 1) == 0);
 
   // Determine whether the incoming request is a Traffic Net request.
   s->traffic_net_req = (incoming_request->method_get_wksidx() == HTTP_WKSIDX_POST)
-    && (ptr_len_cmp(host, host_len, s->http_config_param->tn_server,
-                    s->http_config_param->tn_server_len) == 0)
+    && (ptr_len_cmp(host, host_len, s->http_config_param->tn_server, s->http_config_param->tn_server_len) == 0)
     && (port == s->http_config_param->tn_port);
 
   //////////////////////////////////////////////////////////////////
@@ -831,6 +831,12 @@ HttpTransact::StartRemapRequest(State * 
   }
 
   Debug("http_trans", "END HttpTransact::StartRemapRequest");
+  TRANSACT_RETURN(HTTP_API_PRE_REMAP, HttpTransact::PerformRemap);
+}
+
+void HttpTransact::PerformRemap(State *s)
+{
+  Debug("http_trans","Inside PerformRemap");
   TRANSACT_RETURN(HTTP_REMAP_REQUEST, HttpTransact::EndRemapRequest);
 }
 
@@ -844,7 +850,8 @@ HttpTransact::EndRemapRequest(State * s)
   int method = incoming_request->method_get_wksidx();
   int host_len;
   const char *host = incoming_request->host_get(&host_len);
-
+  Debug("http_trans","EndRemapRequest host is %.*s", host_len,host);
+  
   ////////////////////////////////////////////////////////////////
   // if we got back a URL to redirect to, vector the user there //
   ////////////////////////////////////////////////////////////////
@@ -966,13 +973,22 @@ done:
     obj_describe(s->hdr_info.client_request.m_http, 1);
   }
 
-  if (!s->reverse_proxy) {
+  /*
+    if s->reverse_proxy == false, we can assume remapping failed in some way
+      -however-
+    If an API setup a tunnel to fake the origin or proxy's response we will 
+    continue to handle the request (as this was likely the plugin author's intent)
+    
+    otherwise, 502/404 the request right now. /eric
+  */
+  if (!s->reverse_proxy && s->state_machine->plugin_tunnel_type == HTTP_NO_PLUGIN_TUNNEL) {
     Debug("http_trans", "END HttpTransact::EndRemapRequest");
     HTTP_INCREMENT_TRANS_STAT(http_invalid_client_requests_stat);
     TRANSACT_RETURN(PROXY_SEND_ERROR_CACHE_NOOP, NULL);
   } else {
+    s->hdr_info.client_response.clear(); //anything previously set is invalid from this point forward
     Debug("http_trans", "END HttpTransact::EndRemapRequest");
-    TRANSACT_RETURN(HTTP_API_READ_REQUEST_HDR, HttpTransact::HandleRequest);
+    TRANSACT_RETURN(HTTP_API_POST_REMAP, HttpTransact::HandleRequest);
   }
 
   ink_debug_assert(!"not reached");
@@ -1092,13 +1108,13 @@ HttpTransact::ModifyRequest(State * s)
 
   Debug("http_trans", "END HttpTransact::ModifyRequest");
 
-  TRANSACT_RETURN(HTTP_API_READ_REQUEST_PRE_REMAP, HttpTransact::StartRemapRequest);
+  TRANSACT_RETURN(HTTP_API_READ_REQUEST_HDR, HttpTransact::StartRemapRequest);
 }
 
 void
 HttpTransact::HandleRequest(State * s)
 {
-  Debug("http_trans", "START HttpTransact/HandleRequest");
+  Debug("http_trans", "START HttpTransact::HandleRequest");
 
   HTTP_DEBUG_ASSERT(!s->hdr_info.server_request.valid());
 
@@ -1285,7 +1301,7 @@ HttpTransact::HandleApiErrorJump(State *
   Debug("http_trans", "[HttpTransact::HandleApiErrorJump]");
 
   // since the READ_REQUEST_HDR_HOOK is processed before
-  //   we examine the request, returning INK_EVENT_ERROR will cause
+  //   we examine the request, returning TS_EVENT_ERROR will cause
   //   the protocol in the via string to be "?"  Set it here
   //   since we know it has to be http
   // For CONNECT method, next_hop_scheme is NULL
@@ -1301,9 +1317,19 @@ HttpTransact::HandleApiErrorJump(State *
     s->hdr_info.client_response.fields_clear();
     s->source = SOURCE_INTERNAL;
   }
-
-  build_response(s, &s->hdr_info.client_response,
-                 s->client_info.http_version, HTTP_STATUS_INTERNAL_SERVER_ERROR, "INKApi Error");
+  
+  /** 
+    The API indicated an error. Lets use a >=400 error from the state (if one's set) or fallback to a 
+    generic HTTP/1.X 500 INKApi Error
+  **/
+  if ( s->http_return_code && s->http_return_code >= HTTP_STATUS_BAD_REQUEST ) {
+    build_response(s, &s->hdr_info.client_response,
+                   s->client_info.http_version, s->http_return_code, http_hdr_reason_lookup(s->http_return_code)?:"Error" );
+  }
+  else {
+    build_response(s, &s->hdr_info.client_response,
+                   s->client_info.http_version, HTTP_STATUS_INTERNAL_SERVER_ERROR, "INKApi Error");
+  }  
 
   TRANSACT_RETURN(PROXY_INTERNAL_CACHE_NOOP, NULL);
   return;
@@ -2809,8 +2835,7 @@ HttpTransact::build_response_from_cache(
       // Check if cached response supports Range. If it does, append
       // Range transformation plugin
       // only if the cached response is a 200 OK
-      if (client_response_code == HTTP_STATUS_OK && client_request->presence(MIME_PRESENCE_RANGE) &&
-          (cache_global_hooks == NULL || cache_global_hooks->hooks_set <= 0)) {
+      if (client_response_code == HTTP_STATUS_OK && client_request->presence(MIME_PRESENCE_RANGE)) {
         s->state_machine->do_range_setup_if_necessary();
         if (s->range_setup == RANGE_NOT_SATISFIABLE &&
             s->http_config_param->reverse_proxy_enabled) {
@@ -4229,9 +4254,7 @@ HttpTransact::handle_cache_operation_on_
 
       if (is_request_conditional(&s->hdr_info.client_request)) {
         client_response_code =
-          HttpTransactCache::match_response_to_request_conditionals(&s->
-                                                                    hdr_info.
-                                                                    client_request,
+          HttpTransactCache::match_response_to_request_conditionals(&s->hdr_info.client_request,
                                                                     s->cache_info.object_read->response_get());
       } else {
         client_response_code = HTTP_STATUS_OK;
@@ -4266,9 +4289,7 @@ HttpTransact::handle_cache_operation_on_
       if (is_request_conditional(&s->hdr_info.client_request)) {
         if (s->http_config_param->cache_when_to_revalidate != 4)
           client_response_code =
-            HttpTransactCache::match_response_to_request_conditionals(&s->
-                                                                      hdr_info.
-                                                                      client_request,
+            HttpTransactCache::match_response_to_request_conditionals(&s->hdr_info.client_request,
                                                                       s->cache_info.object_read->response_get());
         else
           client_response_code = server_response_code;
@@ -4385,13 +4406,8 @@ HttpTransact::handle_cache_operation_on_
       base_response->unset_cooked_cc_need_revalidate_once();
 
       if (is_request_conditional(&s->hdr_info.client_request) &&
-          HttpTransactCache::match_response_to_request_conditionals(&s->
-                                                                    hdr_info.
-                                                                    client_request,
-                                                                    s->
-                                                                    cache_info.
-                                                                    object_read->
-                                                                    response_get()) == HTTP_STATUS_NOT_MODIFIED) {
+          HttpTransactCache::match_response_to_request_conditionals(&s->hdr_info.client_request,
+                                                                    s->cache_info.object_read->response_get()) == HTTP_STATUS_NOT_MODIFIED) {
         s->next_action = HttpTransact::PROXY_INTERNAL_CACHE_UPDATE_HEADERS;
         client_response_code = HTTP_STATUS_NOT_MODIFIED;
       } else {
@@ -4422,8 +4438,7 @@ HttpTransact::handle_cache_operation_on_
       if (s->next_action == HttpTransact::SERVE_FROM_CACHE && s->state_machine->do_transform_open()) {
         set_header_for_transform(s, base_response);
       } else {
-        build_response(s, base_response, &s->hdr_info.client_response,
-                       s->client_info.http_version, client_response_code);
+        build_response(s, base_response, &s->hdr_info.client_response, s->client_info.http_version, client_response_code);
       }
 
       return;
@@ -4509,9 +4524,8 @@ HttpTransact::handle_cache_operation_on_
         Debug("http_trans", "[hcoofsr] conditional request, 200 " "response, send back 304 if possible");
 
         client_response_code =
-          HttpTransactCache::match_response_to_request_conditionals(&s->
-                                                                    hdr_info.
-                                                                    client_request, &s->hdr_info.server_response);
+          HttpTransactCache::match_response_to_request_conditionals(&s->hdr_info.client_request,
+                                                                    &s->hdr_info.server_response);
 
         if ((client_response_code == HTTP_STATUS_NOT_MODIFIED) ||
             (client_response_code == HTTP_STATUS_PRECONDITION_FAILED)) {
@@ -4898,7 +4912,7 @@ HttpTransact::handle_transform_ready(Sta
 void
 HttpTransact::set_header_for_transform(State * s, HTTPHdr * base_header)
 {
-#ifndef INK_NO_TRANSFORM
+#ifndef TS_NO_TRANSFORM
   s->hdr_info.transform_response.create(HTTP_TYPE_RESPONSE);
   s->hdr_info.transform_response.copy(base_header);
 
@@ -4911,7 +4925,7 @@ HttpTransact::set_header_for_transform(S
     DUMP_HEADER("http_hdrs", &s->hdr_info.transform_response, s->state_machine_id, "Header To Transform");
 #else
   ink_assert(!"transformation not supported\n");
-#endif //INK_NO_TRANSFORM
+#endif // TS_NO_TRANSFORM
 }
 
 void
@@ -5357,18 +5371,17 @@ HttpTransact::handle_msie_reload_badness
 void
 HttpTransact::add_client_ip_to_outgoing_request(State * s, HTTPHdr * request)
 {
-  char ip_string[32];
-  size_t ip_string_size;
-  bool client_ip_set;
+  char ip_string[INET6_ADDRSTRLEN + 1] = {'\0'};
+  size_t ip_string_size = 0;
   unsigned char *p = (unsigned char *) &(s->client_info.ip);
 
   if (unlikely(!p))
     return;
 
-  // Always prepare the IP string. ip_to_str() expects host order instead of network order
-  if (LogUtils::ip_to_str(ntohl(s->client_info.ip), ip_string + 1, 30, &ip_string_size) == 0) {
+  // Always prepare the IP string.
+  if (ink_inet_ntop((struct sockaddr *)&(s->client_info.addr), ip_string + 1, sizeof(ip_string) - 1) != NULL) {
     ip_string[0] = ' ';         // Leading space always, in case we need to concatenate this IP
-    ip_string_size += 1;
+    ip_string_size += strlen(ip_string);
   } else {
     // Failure, omg
     ip_string_size = 0;
@@ -5379,7 +5392,7 @@ HttpTransact::add_client_ip_to_outgoing_
   // if we want client-ip headers, and there isn't one, add one //
   ////////////////////////////////////////////////////////////////
   if ((s->http_config_param->anonymize_insert_client_ip) && (!s->http_config_param->anonymize_remove_client_ip)) {
-    client_ip_set = request->presence(MIME_PRESENCE_CLIENT_IP);
+    bool client_ip_set = request->presence(MIME_PRESENCE_CLIENT_IP);
     Debug("http_trans", "client_ip_set = %d", client_ip_set);
 
     if (!client_ip_set && ip_string_size > 1) {
@@ -5965,26 +5978,12 @@ HttpTransact::initialize_state_variables
     s->hdr_info.response_content_length = 0;
     s->hdr_info.trust_response_cl = true;
   } else {
-    ////////////////////////////////////////////////////////
-    // this is the case that the origin server sent       //
-    // us content length. Experience says that many       //
-    // origin servers that do not support keep-alive      //
-    // lie about the content length. to avoid truncation  //
-    // of docuemnts from such server, if the server is    //
-    // not keep-alive, we set to read until the server    //
-    // closes the connection. We sent the maybe bogus     //
-    // content length to the browser, and we will correct //
-    // the cache if it turnrd out that the servers lied.  //
-    ////////////////////////////////////////////////////////
+    // This code used to discriminate CL: headers when the origin disabled keep-alive.
     if (incoming_response->presence(MIME_PRESENCE_CONTENT_LENGTH)) {
-      if (s->current.server->keep_alive == HTTP_NO_KEEPALIVE) {
-        s->hdr_info.trust_response_cl = false;
-        s->hdr_info.response_content_length = HTTP_UNDEFINED_CL;
-      } else {
-        int64 cl = incoming_response->get_content_length();
-        s->hdr_info.response_content_length = (cl >= 0) ? cl : HTTP_UNDEFINED_CL;
-        s->hdr_info.trust_response_cl = true;
-      }
+      int64 cl = incoming_response->get_content_length();
+
+      s->hdr_info.response_content_length = (cl >= 0) ? cl : HTTP_UNDEFINED_CL;
+      s->hdr_info.trust_response_cl = true;
     } else {
       s->hdr_info.response_content_length = HTTP_UNDEFINED_CL;
       s->hdr_info.trust_response_cl = false;
@@ -6081,8 +6080,7 @@ HttpTransact::is_cache_response_returnab
   }
   // If cookies in response and no TTL set, we do not cache the doc
   if ((s->cache_control.ttl_in_cache <= 0) &&
-      do_cookies_prevent_caching((int) s->http_config_param->
-                                 cache_responses_to_cookies,
+      do_cookies_prevent_caching((int) s->http_config_param->cache_responses_to_cookies,
                                  &s->hdr_info.client_request,
                                  s->cache_info.object_read->response_get(), s->cache_info.object_read->request_get())) {
     SET_VIA_STRING(VIA_CACHE_RESULT, VIA_IN_CACHE_NOT_ACCEPTABLE);
@@ -7380,8 +7378,7 @@ HttpTransact::delete_all_document_altern
     } else {
       if (valid_max_forwards) {
         --max_forwards;
-        Debug("http_trans",
-              "[delete_all_document_alternates_and_return] " "Decrementing max_forwards to %d", max_forwards);
+        Debug("http_trans", "[delete_all_document_alternates_and_return] " "Decrementing max_forwards to %d", max_forwards);
         s->hdr_info.client_request.value_set_int(MIME_FIELD_MAX_FORWARDS, MIME_LEN_MAX_FORWARDS, max_forwards);
       }
     }
@@ -8199,10 +8196,8 @@ HttpTransact::build_response(State * s,
       HttpTransactHeaders::process_connection_headers(base_response, outgoing_response);
 
       if (s->http_config_param->insert_age_in_response)
-        HttpTransactHeaders::insert_time_and_age_headers_in_response(s->
-                                                                     request_sent_time,
-                                                                     s->
-                                                                     response_received_time,
+        HttpTransactHeaders::insert_time_and_age_headers_in_response(s->request_sent_time,
+                                                                     s->response_received_time,
                                                                      s->current.now, base_response, outgoing_response);
 
       // Note: We need to handle the "Content-Length" header first here
@@ -8626,16 +8621,15 @@ HttpTransact::build_redirect_response(St
   s->internal_msg_buffer_fast_allocator_size = -1;
 
   s->internal_msg_buffer =
-    body_factory->
-    fabricate_with_old_api_build_va("redirect#moved_temporarily", s, 8192,
-                                    &(s->internal_msg_buffer_size),
-                                    body_language, sizeof(body_language),
-                                    body_type, sizeof(body_type), 
-                                    status_code,
-                                    reason_phrase,
-                                    "%s <a href=\"%s\">%s</a>.  %s.",
-                                    "The document you requested is now",
-                                    new_url, new_url, "Please update your documents and bookmarks accordingly", NULL);
+    body_factory->fabricate_with_old_api_build_va("redirect#moved_temporarily", s, 8192,
+                                                  &(s->internal_msg_buffer_size),
+                                                  body_language, sizeof(body_language),
+                                                  body_type, sizeof(body_type), 
+                                                  status_code,
+                                                  reason_phrase,
+                                                  "%s <a href=\"%s\">%s</a>.  %s.",
+                                                  "The document you requested is now",
+                                                  new_url, new_url, "Please update your documents and bookmarks accordingly", NULL);
 
 
   h->set_content_length(s->internal_msg_buffer_size);
@@ -8699,8 +8693,7 @@ ink_cluster_time(void)
 //      highest_delta = 0L;
 //     }
 
-  Debug("http_trans",
-        "[ink_cluster_time] local: %ld, highest_delta: %d, cluster: %ld",
+  Debug("http_trans", "[ink_cluster_time] local: %ld, highest_delta: %d, cluster: %ld",
         local_time, highest_delta, (local_time + (ink_time_t) highest_delta));
 
   HTTP_DEBUG_ASSERT(highest_delta >= 0);
@@ -8891,6 +8884,62 @@ HttpTransact::client_result_stat(State *
   } else if (s->client_info.abort == MAYBE_ABORTED) {
     client_transaction_result = CLIENT_TRANSACTION_RESULT_ERROR_POSSIBLE_ABORT;
   }
+  // Count the status codes, assuming the client didn't abort (i.e. there is an m_http)
+  if ((s->source != SOURCE_NONE) && (s->client_info.abort == DIDNOT_ABORT)) {
+    int status_code = s->hdr_info.client_response.status_get();
+
+    switch(status_code) {
+    case 100: HTTP_SUM_TRANS_STAT(http_response_status_100_count_stat, 1); break;
+    case 101: HTTP_SUM_TRANS_STAT(http_response_status_101_count_stat, 1); break;
+    case 200: HTTP_SUM_TRANS_STAT(http_response_status_200_count_stat, 1); break;
+    case 201: HTTP_SUM_TRANS_STAT(http_response_status_201_count_stat, 1); break;
+    case 202: HTTP_SUM_TRANS_STAT(http_response_status_202_count_stat, 1); break;
+    case 203: HTTP_SUM_TRANS_STAT(http_response_status_203_count_stat, 1); break;
+    case 204: HTTP_SUM_TRANS_STAT(http_response_status_204_count_stat, 1); break;
+    case 205: HTTP_SUM_TRANS_STAT(http_response_status_205_count_stat, 1); break;
+    case 206: HTTP_SUM_TRANS_STAT(http_response_status_206_count_stat, 1); break;
+    case 300: HTTP_SUM_TRANS_STAT(http_response_status_300_count_stat, 1); break;
+    case 301: HTTP_SUM_TRANS_STAT(http_response_status_301_count_stat, 1); break;
+    case 302: HTTP_SUM_TRANS_STAT(http_response_status_302_count_stat, 1); break;
+    case 303: HTTP_SUM_TRANS_STAT(http_response_status_303_count_stat, 1); break;
+    case 304: HTTP_SUM_TRANS_STAT(http_response_status_304_count_stat, 1); break;
+    case 305: HTTP_SUM_TRANS_STAT(http_response_status_305_count_stat, 1); break;
+    case 307: HTTP_SUM_TRANS_STAT(http_response_status_307_count_stat, 1); break;
+    case 400: HTTP_SUM_TRANS_STAT(http_response_status_400_count_stat, 1); break;
+    case 401: HTTP_SUM_TRANS_STAT(http_response_status_401_count_stat, 1); break;
+    case 402: HTTP_SUM_TRANS_STAT(http_response_status_402_count_stat, 1); break;
+    case 403: HTTP_SUM_TRANS_STAT(http_response_status_403_count_stat, 1); break;
+    case 404: HTTP_SUM_TRANS_STAT(http_response_status_404_count_stat, 1); break;
+    case 405: HTTP_SUM_TRANS_STAT(http_response_status_405_count_stat, 1); break;
+    case 406: HTTP_SUM_TRANS_STAT(http_response_status_406_count_stat, 1); break;
+    case 407: HTTP_SUM_TRANS_STAT(http_response_status_407_count_stat, 1); break;
+    case 408: HTTP_SUM_TRANS_STAT(http_response_status_408_count_stat, 1); break;
+    case 409: HTTP_SUM_TRANS_STAT(http_response_status_409_count_stat, 1); break;
+    case 410: HTTP_SUM_TRANS_STAT(http_response_status_410_count_stat, 1); break;
+    case 411: HTTP_SUM_TRANS_STAT(http_response_status_411_count_stat, 1); break;
+    case 412: HTTP_SUM_TRANS_STAT(http_response_status_412_count_stat, 1); break;
+    case 413: HTTP_SUM_TRANS_STAT(http_response_status_413_count_stat, 1); break;
+    case 414: HTTP_SUM_TRANS_STAT(http_response_status_414_count_stat, 1); break;
+    case 415: HTTP_SUM_TRANS_STAT(http_response_status_415_count_stat, 1); break;
+    case 416: HTTP_SUM_TRANS_STAT(http_response_status_416_count_stat, 1); break;
+    case 500: HTTP_SUM_TRANS_STAT(http_response_status_500_count_stat, 1); break;
+    case 501: HTTP_SUM_TRANS_STAT(http_response_status_501_count_stat, 1); break;
+    case 502: HTTP_SUM_TRANS_STAT(http_response_status_502_count_stat, 1); break;
+    case 503: HTTP_SUM_TRANS_STAT(http_response_status_503_count_stat, 1); break;
+    case 504: HTTP_SUM_TRANS_STAT(http_response_status_504_count_stat, 1); break;
+    case 505: HTTP_SUM_TRANS_STAT(http_response_status_505_count_stat, 1); break;
+    default: break;
+    }
+    switch(status_code / 100) {
+    case 1: HTTP_SUM_TRANS_STAT(http_response_status_1xx_count_stat, 1); break;
+    case 2: HTTP_SUM_TRANS_STAT(http_response_status_2xx_count_stat, 1); break;
+    case 3: HTTP_SUM_TRANS_STAT(http_response_status_3xx_count_stat, 1); break;
+    case 4: HTTP_SUM_TRANS_STAT(http_response_status_4xx_count_stat, 1); break;
+    case 5: HTTP_SUM_TRANS_STAT(http_response_status_5xx_count_stat, 1); break;
+    default: break;
+    }
+  }
+  
   // Increment the completed connection count
   HTTP_SUM_TRANS_STAT(http_completed_requests_stat, 1);
 
@@ -8965,56 +9014,6 @@ HttpTransact::origin_server_connection_s
 }
 
 void
-HttpTransact::update_aol_stats(State * s, ink_hrtime cache_lookup_time)
-{
-#ifndef TS_MICRO
-  // Interested in stats about JG compressed images.  First
-  //   check the port attribute for a fast path when we are not
-  //   doing jg compression as the integer compare is much cheaper
-  //   than a header fetch & string compare
-  //
-  if (s->client_info.port_attribute == SERVER_PORT_COMPRESSED && s->hdr_info.client_response.valid()) {
-
-    int cont_type_len;
-    const char *cont_type_str = s->hdr_info.client_response.value_get(MIME_FIELD_CONTENT_TYPE,
-                                                                      MIME_LEN_CONTENT_TYPE,
-                                                                      &cont_type_len);
-
-    // This is how we will determine that this was a "JG" request.
-    if (cont_type_str && (ptr_len_casecmp(cont_type_str, cont_type_len, "image/x-jg") == 0)) {
-
-      if (s->squid_codes.wuts_proxy_status_code ==
-          WUTS_PROXY_STATUS_CLIENT_ABORT ||
-          s->squid_codes.log_code == SQUID_LOG_ERR_CLIENT_ABORT ||
-          s->squid_codes.wuts_proxy_status_code ==
-          WUTS_PROXY_STATUS_SPIDER_MEMBER_ABORTED || s->squid_codes.log_code == SQUID_LOG_ERR_SPIDER_MEMBER_ABORTED) {
-        HTTP_INCREMENT_TRANS_STAT(http_jg_client_aborts_stat);
-      }
-
-      if (s->squid_codes.log_code == SQUID_LOG_TCP_HIT ||
-          s->squid_codes.log_code == SQUID_LOG_TCP_MEM_HIT ||
-          s->squid_codes.log_code == SQUID_LOG_TCP_REFRESH_HIT || s->squid_codes.log_code == SQUID_LOG_TCP_IMS_HIT) {
-        HTTP_INCREMENT_TRANS_STAT(http_jg_cache_hits_stat);
-        if (cache_lookup_time > 0) {
-          HTTP_SUM_TRANS_STAT(http_jg_cache_hit_time_stat, cache_lookup_time);
-        }
-      } else {
-        HTTP_INCREMENT_TRANS_STAT(http_jg_cache_misses_stat);
-        if (cache_lookup_time > 0) {
-          HTTP_SUM_TRANS_STAT(http_jg_cache_miss_time_stat, cache_lookup_time);
-        }
-      }
-    }
-
-  }
-#endif
-}
-
-
-
-
-
-void
 HttpTransact::update_size_and_time_stats(State * s, ink_hrtime total_time, ink_hrtime user_agent_write_time,
                                          ink_hrtime origin_server_read_time, ink_hrtime cache_lookup_time,
                                          int user_agent_request_header_size, int64 user_agent_request_body_size,
@@ -9162,8 +9161,6 @@ HttpTransact::update_size_and_time_stats
     origin_server_connection_speed(s, origin_server_read_time, origin_server_response_size);
   }
 
-  update_aol_stats(s, cache_lookup_time);
-
   return;
 }
 
@@ -9324,8 +9321,8 @@ HttpTransact::ConnectionCollapsing(State
           s->state_machine->piggybacking_scheduled = true;
 
           //Scheduling the piggy backed clients to do Cache lookup
-          s->state_machine->event_scheduled = s->state_machine->mutex->
-            thread_holding->schedule_at(s->state_machine, HRTIME_MSECONDS(HttpConfig::m_master.rww_wait_time));
+          s->state_machine->event_scheduled =
+            s->state_machine->mutex->thread_holding->schedule_at(s->state_machine, HRTIME_MSECONDS(HttpConfig::m_master.rww_wait_time));
 
           return CONNECTION_COLLAPSING_SCHEDULED;
         }

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.h?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.h (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.h Tue Nov 30 01:42:55 2010
@@ -486,7 +486,7 @@ public:
     TOTAL_RESPONSE_ERROR_TYPES
   };
 
-  // Please do not forget to fix INKServerState (ts/ts.h)
+  // Please do not forget to fix TSServerState (ts/ts.h)
   // in case of any modifications in ServerState_t
   enum ServerState_t
   {
@@ -585,10 +585,13 @@ public:
     CONTINUE,
 
     HTTP_API_SM_START,
-    HTTP_API_READ_REQUEST_PRE_REMAP,
-    HTTP_REMAP_REQUEST,
-    HTTP_END_REMAP_REQUEST,
+    
     HTTP_API_READ_REQUEST_HDR,
+    HTTP_API_PRE_REMAP,
+    HTTP_REMAP_REQUEST,
+    HTTP_API_POST_REMAP,
+    HTTP_POST_REMAP_SKIP,
+    
     HTTP_API_OS_DNS,
     HTTP_API_SEND_REQUEST_HDR,
     HTTP_API_READ_CACHE_HDR,
@@ -785,6 +788,7 @@ public:
     // components is a byte, so:
     // 0x25364758 = 0x25.0x36.0x47.0x58 = 37.54.71.88 in decimal.
     unsigned int ip;
+    struct sockaddr_storage addr;
 
     // port to connect to, except for client
     // connection where it is port on proxy
@@ -812,7 +816,9 @@ public:
         abort(ABORT_UNDEFINED),
         port_attribute(SERVER_PORT_DEFAULT),
         is_transparent(false)
-    { }
+    {
+      memset(&addr, 0, sizeof(addr));
+    }
   } ConnectionAttributes;
 
   typedef struct _CurrentInfo
@@ -896,7 +902,6 @@ public:
   } SquidLogInfo;
 
 
-#define HTTP_TRANSACT_STATE_MAX_USER_ARG         16     /* max number of user arguments inside HttpTransact::State structure */
 #define HTTP_TRANSACT_STATE_MAX_XBUF_SIZE  (1024*2)     /* max size of plugin exchange buffer */
 
   struct State
@@ -904,7 +909,6 @@ public:
     HttpTransactMagic_t m_magic;
 
     HttpSM *state_machine;
-    NewCacheVC *cache_vc;
 
     Arena arena;
 
@@ -1007,7 +1011,7 @@ public:
     int return_xbuf_size;
     bool return_xbuf_plain;
     char return_xbuf[HTTP_TRANSACT_STATE_MAX_XBUF_SIZE];
-    void *user_args[HTTP_TRANSACT_STATE_MAX_USER_ARG];
+    void *user_args[HTTP_SSN_TXN_MAX_USER_ARG];
 
     int api_txn_active_timeout_value;
     int api_txn_connect_timeout_value;
@@ -1054,7 +1058,8 @@ public:
 
     bool already_downgraded;
     URL pristine_url;  // pristine url is the url before remap
-
+    
+    bool api_skip_all_remapping;
 
     // Methods
     void
@@ -1066,7 +1071,7 @@ public:
 
     // Constructor
     State()
-      : m_magic(HTTP_TRANSACT_MAGIC_ALIVE), state_machine(NULL), cache_vc(NULL), http_config_param(NULL), force_dns(false),
+      : m_magic(HTTP_TRANSACT_MAGIC_ALIVE), state_machine(NULL), http_config_param(NULL), force_dns(false),
         updated_server_version(HostDBApplicationInfo::HTTP_VERSION_UNDEFINED), is_revalidation_necessary(false),
         HashTable_Tries(0),             //YTS Team, yamsat
         request_will_not_selfloop(false),       //YTS Team, yamsat
@@ -1146,7 +1151,8 @@ public:
         congestion_congested_or_failed(0),
         congestion_connection_opened(0),
         reverse_proxy(false), url_remap_success(false), remap_redirect(NULL), filter_mask(0), already_downgraded(false),
-        pristine_url()
+        pristine_url(),
+        api_skip_all_remapping(false)
     {
       int i;
       char *via_ptr = via_string;
@@ -1200,11 +1206,6 @@ public:
       record_transaction_stats();
       m_magic = HTTP_TRANSACT_MAGIC_DEAD;
 
-      if (cache_vc) {
-        cache_vc->free();
-        cache_vc = NULL;
-      }
-
       if (internal_msg_buffer) {
         free_internal_msg_buffer(internal_msg_buffer, internal_msg_buffer_fast_allocator_size);
       }
@@ -1259,6 +1260,7 @@ public:
   static void StartRemapRequest(State * s);
   static void RemapRequest(State * s);
   static void EndRemapRequest(State * s);
+  static void PerformRemap(State * s);
   static void ModifyRequest(State * s);
   static void HandleRequest(State * s);
   static bool handleIfRedirect(State * s);
@@ -1401,7 +1403,6 @@ public:
                                          int origin_server_request_header_size, int64 origin_server_request_body_size,
                                          int origin_server_response_header_size, int64 origin_server_response_body_size,
                                          int pushed_response_header_size, int64 pushed_response_body_size, CacheAction_t cache_action);
-  static void update_aol_stats(State * s, ink_hrtime cache_lookup_time);
   static void histogram_request_document_size(State * s, int64 size);
   static void histogram_response_document_size(State * s, int64 size);
   static void user_agent_connection_speed(State * s, ink_hrtime transfer_time, int64 nbytes);

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactCache.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactCache.cc?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactCache.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactCache.cc Tue Nov 30 01:42:55 2010
@@ -415,7 +415,7 @@ HttpTransactCache::calculate_quality_of_
     HttpAltInfo info;
     float qvalue;
 
-    hook = http_global_hooks->get(INK_HTTP_SELECT_ALT_HOOK);
+    hook = http_global_hooks->get(TS_HTTP_SELECT_ALT_HOOK);
     if (hook) {
       info.m_client_req.copy_shallow(client_request);
       info.m_cached_req.copy_shallow(obj_client_request);
@@ -424,7 +424,7 @@ HttpTransactCache::calculate_quality_of_
 
       while (hook) {
         info.m_qvalue = 1.0;
-        hook->invoke(INK_EVENT_HTTP_SELECT_ALT, &info);
+        hook->invoke(TS_EVENT_HTTP_SELECT_ALT, &info);
         hook = hook->m_link.next;
         if (info.m_qvalue < 0.0) {
           info.m_qvalue = 0.0;

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.cc?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.cc Tue Nov 30 01:42:55 2010
@@ -494,64 +494,6 @@ HttpTransactHeaders::downgrade_request(b
 
   return true;
 }
-
-
-bool
-HttpTransactHeaders::generate_basic_authorization_from_request(Arena *arena, HTTPHdr *h, char **username, char **password)
-{
-  const char *auth_value;
-  const char *auth_end;
-  const char *ciphertext;
-  const char *name_password;
-  const char *name_password_end;
-  const char *password_p;
-  const char *username_p;
-  int auth_len, username_len, password_len;
-  int name_password_len;
-
-  *username = NULL;
-  *password = NULL;
-
-  auth_value = h->value_get(MIME_FIELD_AUTHORIZATION, MIME_LEN_AUTHORIZATION, &auth_len);
-  if (!auth_value)
-    return false;
-  auth_end = auth_value + auth_len;
-
-  // NOTE: strncasecmp_eow returns true on a match!
-  if (ParseRules::strncasecmp_eow(auth_value, "Basic ", min(6, auth_len)) == 0)
-    return (false);
-
-  // skip whitespace up to the start of the ciphertext
-  for (ciphertext = auth_value + 5; ((ciphertext < auth_end) && ParseRules::is_ws(*ciphertext)); ++ciphertext);
-
-  // decode the encoded name+password, placing it in xmalloc'd memory
-  if (!(name_password = ink_base64_decode((char *) ciphertext, (auth_end - ciphertext), &name_password_len)))
-    return (false);
-
-  name_password_end = name_password + name_password_len;
-
-  // search for last ':' in the name_password string
-  for (password_p = name_password_end - 1; (password_p >= name_password) && (*password_p != ':'); password_p--);
-  if (password_p < name_password) {
-    xfree((void *) name_password);
-    return (false);
-  }
-  // isolate name & password pieces
-  password_p += 1;
-  username_p = name_password;
-
-  username_len = password_p - username_p - 1;
-  password_len = name_password_end - password_p;
-
-  *username = arena->str_store(username_p, username_len);
-  *password = arena->str_store(password_p, password_len);
-
-  xfree((void *) name_password);
-
-  return (true);
-}
-
-
 bool
 HttpTransactHeaders::get_wuts_code(HTTPHdr * hdr, WUTSCode * w)
 {
@@ -1005,31 +947,20 @@ void
 HttpTransactHeaders::insert_warning_header(HttpConfigParams *http_config_param, HTTPHdr *header, HTTPWarningCode code,
                                            const char *warn_text, int warn_text_len)
 {
-  char *p;
-  char *warning_text = NULL;
-  int bufsize, i, warning_text_len;
+  int bufsize, len;
 
   // + 23 for 20 possible digits of warning code (long long max
   //  digits) & 2 spaces & the string terminator
   bufsize = http_config_param->proxy_response_via_string_len + 23;
   if (warn_text != NULL)
     bufsize += warn_text_len;
+  else
+    warn_text_len = 0; // Make sure it's really zero
 
-  warning_text = (char *) xmalloc(bufsize);
-  snprintf(warning_text, bufsize, "%3d %s ", code, http_config_param->proxy_response_via_string);
-
-  p = warning_text + strlen(warning_text);
-
-  if (warn_text) {
-    for (i = 0; i < warn_text_len; i++)
-      *p++ = warn_text[i];
-  }
-
-  warning_text_len = p - warning_text;
-
-  header->value_set(MIME_FIELD_WARNING, MIME_LEN_WARNING, warning_text, warning_text_len);
+  char warning_text[bufsize];
 
-  xfree(warning_text);
+  len = snprintf(warning_text, bufsize, "%3d %s %.*s", code, http_config_param->proxy_response_via_string, warn_text_len, warn_text);
+  header->value_set(MIME_FIELD_WARNING, MIME_LEN_WARNING, warning_text, len);
 }
 
 

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.h?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.h (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTransactHeaders.h Tue Nov 30 01:42:55 2010
@@ -68,7 +68,6 @@ public:
   static bool does_server_allow_response_to_be_stored(HTTPHdr * resp);
   static bool downgrade_request(bool * origin_server_keep_alive, HTTPHdr * outgoing_request);
 
-  static bool generate_basic_authorization_from_request(Arena *arena, HTTPHdr *h, char **username, char **password);
   static bool get_wuts_code(HTTPHdr * hdr, WUTSCode * w);
   static void set_wuts_codes(HTTPHdr * hdr, WUTSCode * code);
   static void set_wuts_codes(HTTPHdr * hdr, SquidHitMissCode hit_miss_code,

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.cc?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.cc Tue Nov 30 01:42:55 2010
@@ -59,6 +59,7 @@ chunked_reenable(HttpTunnelProducer * p,
     //   the incoming buffer that we haven't processed yet
     //   Only process it if we determine the client isn't overflowed
     MIOBuffer *dbuf = p->chunked_handler.dechunked_buffer;
+
     if (dbuf->max_read_avail() < max_chunked_ahead_bytes && dbuf->max_block_count() < max_chunked_ahead_blocks) {
       // Flow control no longer needed.  We only initiate flow control
       //  after completing a chunk so we know the next state is
@@ -67,8 +68,7 @@ chunked_reenable(HttpTunnelProducer * p,
       p->chunked_handler.state = ChunkedHandler::CHUNK_READ_SIZE_START;
 
       // Call back the tunnel as if we've received more data from the server
-      int r = tunnel->main_handler(p->chunked_handler.last_server_event,
-                                   p->read_vio);
+      int r = tunnel->main_handler(p->chunked_handler.last_server_event, p->read_vio);
 
       // Only actually reenable the server if we've stayed out of the
       //  flow control state.  The callout may have killed the vc
@@ -92,7 +92,6 @@ chunked_reenable(HttpTunnelProducer * p,
 static void
 add_chunked_reenable(HttpTunnelProducer * p, HttpTunnel * tunnel)
 {
-
   if (p->chunked_handler.state != ChunkedHandler::CHUNK_FLOW_CONTROL) {
     p->read_vio->reenable();
   } else {
@@ -107,8 +106,7 @@ add_chunked_reenable(HttpTunnelProducer 
 
       // Call back the tunnel as if we've received more data from
       //   the server
-      int r = tunnel->main_handler(p->chunked_handler.last_server_event,
-                                   p->read_vio);
+      int r = tunnel->main_handler(p->chunked_handler.last_server_event, p->read_vio);
 
       // Only actually reenable the server if we've stayed out of the
       //  flow control state.  The callout may have killed the vc
@@ -131,10 +129,10 @@ init_max_chunk_buf()
   max_chunk_buf_len = snprintf(max_chunk_buf, sizeof(max_chunk_buf), "%x\r\n", max_chunk_size);
 }
 
-ChunkedHandler::ChunkedHandler():
-chunked_reader(NULL), dechunked_buffer(NULL), dechunked_size(0), dechunked_reader(NULL), chunked_buffer(NULL),
-chunked_size(0), truncation(false), skip_bytes(0), state(CHUNK_READ_CHUNK), cur_chunk_size(0),
-bytes_left(0), last_server_event(VC_EVENT_NONE), running_sum(0), num_digits(0)
+ChunkedHandler::ChunkedHandler()
+  : chunked_reader(NULL), dechunked_buffer(NULL), dechunked_size(0), dechunked_reader(NULL), chunked_buffer(NULL),
+    chunked_size(0), truncation(false), skip_bytes(0), state(CHUNK_READ_CHUNK), cur_chunk_size(0),
+    bytes_left(0), last_server_event(VC_EVENT_NONE), running_sum(0), num_digits(0)
 {
 }
 
@@ -172,6 +170,7 @@ ChunkedHandler::read_size()
   while (chunked_reader->read_avail() > 0 && !done) {
     const char *tmp = chunked_reader->start();
     int64 data_size = chunked_reader->block_read_avail();
+
     ink_assert(data_size > 0);
     bytes_used = 0;
 
@@ -250,10 +249,8 @@ ChunkedHandler::transfer_bytes()
     moved = 0;
 
     to_move = MIN(bytes_left, block_read_avail);
-
-    if (to_move <= 0) {
+    if (to_move <= 0)
       break;
-    }
 
     if (to_move >= min_block_transfer_bytes) {
       moved = dechunked_buffer->write(chunked_reader, bytes_left);
@@ -346,7 +343,6 @@ ChunkedHandler::read_trailer()
 bool ChunkedHandler::process_chunked_content()
 {
   while (chunked_reader->read_avail() > 0 && state != CHUNK_READ_DONE && state != CHUNK_READ_ERROR) {
-
     switch (state) {
     case CHUNK_READ_SIZE:
     case CHUNK_READ_SIZE_CRLF:
@@ -371,14 +367,11 @@ bool ChunkedHandler::process_chunked_con
   return (state == CHUNK_READ_DONE || state == CHUNK_READ_ERROR);
 }
 
-
 bool ChunkedHandler::generate_chunked_content()
 {
-  char
-    tmp[16];
+  char tmp[16];
+  bool server_done = false;
 
-  bool
-    server_done = false;
   switch (last_server_event) {
   case VC_EVENT_EOS:
   case VC_EVENT_READ_COMPLETE:
@@ -447,25 +440,25 @@ bool ChunkedHandler::generate_chunked_co
 
 #undef MIN
 
-HttpTunnelProducer::HttpTunnelProducer():
-consumer_list(), self_consumer(NULL),
-vc(NULL), vc_handler(NULL), read_vio(NULL), read_buffer(NULL),
-buffer_start(NULL), vc_type(HT_HTTP_SERVER), chunking_action(TCA_PASSTHRU_DECHUNKED_CONTENT),
-do_chunking(false), do_dechunking(false), do_chunked_passthru(false),
-init_bytes_done(0), nbytes(0), ntodo(0), bytes_read(0), handler_state(0), num_consumers(0), alive(false),
-read_success(false), name(NULL)
+HttpTunnelProducer::HttpTunnelProducer()
+  : consumer_list(), self_consumer(NULL),
+    vc(NULL), vc_handler(NULL), read_vio(NULL), read_buffer(NULL),
+    buffer_start(NULL), vc_type(HT_HTTP_SERVER), chunking_action(TCA_PASSTHRU_DECHUNKED_CONTENT),
+    do_chunking(false), do_dechunking(false), do_chunked_passthru(false),
+    init_bytes_done(0), nbytes(0), ntodo(0), bytes_read(0), handler_state(0), num_consumers(0), alive(false),
+    read_success(false), name(NULL)
 {
 }
 
-HttpTunnelConsumer::HttpTunnelConsumer():
-link(), producer(NULL), self_producer(NULL), vc_type(HT_HTTP_CLIENT), vc(NULL), buffer_reader(NULL),
-vc_handler(NULL), write_vio(NULL), skip_bytes(0), bytes_written(0), handler_state(0), alive(false),
-write_success(false), name(NULL)
+HttpTunnelConsumer::HttpTunnelConsumer()
+  : link(), producer(NULL), self_producer(NULL), vc_type(HT_HTTP_CLIENT), vc(NULL), buffer_reader(NULL),
+    vc_handler(NULL), write_vio(NULL), skip_bytes(0), bytes_written(0), handler_state(0), alive(false),
+    write_success(false), name(NULL)
 {
 }
 
-HttpTunnel::HttpTunnel():
-Continuation(NULL), num_producers(0), num_consumers(0), sm(NULL), active(false)
+HttpTunnel::HttpTunnel()
+  : Continuation(NULL), num_producers(0), num_consumers(0), sm(NULL), active(false)
 {
 }
 
@@ -649,7 +642,6 @@ HttpTunnel::add_consumer(VConnection * v
                          VConnection * producer,
                          HttpConsumerHandler sm_handler, HttpTunnelType_t vc_type, const char *name_arg, int64 skip_bytes)
 {
-
   Debug("http_tunnel", "[%lld] adding consumer '%s'", sm->sm_id, name_arg);
 
   // Find the producer entry
@@ -686,11 +678,13 @@ HttpTunnel::add_consumer(VConnection * v
 void
 HttpTunnel::tunnel_run(HttpTunnelProducer * p_arg)
 {
-  HttpTunnelProducer *p;
+  Debug("http_tunnel", "tunnel_run started, p_arg is %s", p_arg ? "provided" : "NULL");
 
   if (p_arg) {
     producer_run(p_arg);
   } else {
+    HttpTunnelProducer *p;
+
     ink_assert(active == false);
 
     for (int i = 0; i < MAX_PRODUCERS; i++) {
@@ -719,6 +713,7 @@ HttpTunnel::producer_run(HttpTunnelProdu
   // prior to being written into the cache.
   HttpTunnelConsumer *c, *cache_write_consumer = NULL;
   bool transform_consumer = false;
+
   for (c = p->consumer_list.head; c; c = c->link.next) {
     if (c->vc_type == HT_CACHE_WRITE) {
       cache_write_consumer = c;
@@ -737,6 +732,7 @@ HttpTunnel::producer_run(HttpTunnelProdu
   // Determine whether the producer is to perform chunking,
   // dechunking, or chunked-passthough of the incoming response.
   TunnelChunkingAction_t action = p->chunking_action;
+
   // [bug 2579251] static producers won't have handler set
   if (p->vc != HTTP_TUNNEL_STATIC_PRODUCER) {
     if (action == TCA_CHUNK_CONTENT)
@@ -878,7 +874,6 @@ HttpTunnel::producer_run(HttpTunnelProdu
     }
   }                             //end of added logic for partial POST
 
-
   if (p->do_chunking) {
     // remove the chunked reader marker so that it doesn't act like a buffer guard
     p->chunked_handler.chunked_buffer->dealloc_reader(chunked_buffer_start);
@@ -921,22 +916,19 @@ HttpTunnel::producer_run(HttpTunnelProdu
     ink_assert(producer_n >= 0);
 
     if (producer_n == 0) {
-      // Everything is already in the buffer so
-      //  mark the producer as done.  We need to notify
-      //  state machine that everything is done.  We use
-      //  a special event to say the producers is done but
-      //  we didn't do anything
+      // Everything is already in the buffer so mark the producer as done.  We need to notify
+      // state machine that everything is done.  We use a special event to say the producers is
+      // done but we didn't do anything
       p->alive = false;
       p->read_success = true;
-      Debug("http_tunnel", "[%lld] [tunnel_run] producer " "already done", sm->sm_id);
+      Debug("http_tunnel", "[%lld] [tunnel_run] producer already done", sm->sm_id);
       producer_handler(HTTP_TUNNEL_EVENT_PRECOMPLETE, p);
     } else {
       p->read_vio = p->vc->do_io_read(this, producer_n, p->read_buffer);
     }
 
-    // Now that the tunnel has started, we must remove
-    //  producer's reader so that it doesn't act like a buffer
-    // guard
+    // Now that the tunnel has started, we must remove producer's reader so
+    // that it doesn't act like a buffer guard
     p->read_buffer->dealloc_reader(p->buffer_start);
     p->buffer_start = NULL;
   }
@@ -947,8 +939,7 @@ HttpTunnel::producer_handler_dechunked(i
 {
   ink_assert(p->do_chunking);
 
-  Debug("http_tunnel", "[%lld] producer_handler_dechunked [%s %s]", sm->sm_id, p->name,
-        HttpDebugNames::get_event_name(event));
+  Debug("http_tunnel", "[%lld] producer_handler_dechunked [%s %s]", sm->sm_id, p->name, HttpDebugNames::get_event_name(event));
 
   // We only interested in translating certain events
   switch (event) {
@@ -978,8 +969,7 @@ HttpTunnel::producer_handler_chunked(int
 {
   ink_assert(p->do_dechunking || p->do_chunked_passthru);
 
-  Debug("http_tunnel", "[%lld] producer_handler_chunked [%s %s]", sm->sm_id, p->name,
-        HttpDebugNames::get_event_name(event));
+  Debug("http_tunnel", "[%lld] producer_handler_chunked [%s %s]", sm->sm_id, p->name, HttpDebugNames::get_event_name(event));
 
   // We only interested in translating certain events
   switch (event) {
@@ -990,7 +980,6 @@ HttpTunnel::producer_handler_chunked(int
     break;
   default:
     return event;
-
   }
 
   p->chunked_handler.last_server_event = event;
@@ -1093,8 +1082,7 @@ bool HttpTunnel::producer_handler(int ev
   }                             //end of added logic for partial copy of POST
 
 
-  Debug("http_redirect", "[HttpTunnel::producer_handler] enable_redirection: %d event: %d", sm->enable_redirection,
-        event);
+  Debug("http_redirect", "[HttpTunnel::producer_handler] enable_redirection: %d event: %d", sm->enable_redirection, event);
   ink_assert(p->alive == true || event == HTTP_TUNNEL_EVENT_PRECOMPLETE || sm->enable_redirection ||
              (p->self_consumer && p->self_consumer->alive == true));
 
@@ -1326,7 +1314,6 @@ HttpTunnel::finish_all_internal(HttpTunn
   ink_assert(p->alive == false);
   HttpTunnelConsumer *c = p->consumer_list.head;
   int64 total_bytes = 0;
-
   TunnelChunkingAction_t action = p->chunking_action;
 
   while (c) {
@@ -1355,6 +1342,7 @@ HttpTunnel::finish_all_internal(HttpTunn
       ink_assert(c->write_vio->nbytes >= 0);
 
       if (c->write_vio->nbytes < 0) {
+        // TODO: Wtf, printf?
         fprintf(stderr,
                 "[HttpTunnel::finish_all_internal] ERROR: Incorrect total_bytes - c->skip_bytes = %lld\n",
                 (int64) (total_bytes - c->skip_bytes));
@@ -1384,7 +1372,6 @@ HttpTunnel::finish_all_internal(HttpTunn
 void
 HttpTunnel::chain_abort_cache_write(HttpTunnelProducer * p)
 {
-
   HttpTunnelConsumer *c = p->consumer_list.head;
 
   while (c) {
@@ -1454,7 +1441,6 @@ HttpTunnel::close_vc(HttpTunnelConsumer 
 int
 HttpTunnel::main_handler(int event, void *data)
 {
-
   HttpTunnelProducer *p = NULL;
   HttpTunnelConsumer *c = NULL;
   bool sm_callback = false;
@@ -1523,9 +1509,9 @@ HttpTunnel::copy_partial_post_data()
 void
 HttpTunnel::allocate_redirect_postdata_producer_buffer()
 {
+  int alloc_index = buffer_size_to_index(sm->t_state.hdr_info.request_content_length);
 
   ink_release_assert(postbuf->postdata_producer_buffer == NULL);
-  int alloc_index = buffer_size_to_index(sm->t_state.hdr_info.request_content_length);
 
   postbuf->postdata_producer_buffer = new_MIOBuffer(alloc_index);
   postbuf->postdata_producer_reader = postbuf->postdata_producer_buffer->alloc_reader();
@@ -1536,9 +1522,12 @@ HttpTunnel::allocate_redirect_postdata_p
 void
 HttpTunnel::allocate_redirect_postdata_buffers(IOBufferReader * ua_reader)
 {
-  Debug("http_redirect", "[HttpTunnel::allocate_postdata_buffers]");
   int alloc_index = buffer_size_to_index(sm->t_state.hdr_info.request_content_length);
 
+  Debug("http_redirect", "[HttpTunnel::allocate_postdata_buffers]");
+
+  // TODO: This is uncool, shouldn't this use the class allocator or proxy allocator ?
+  // If fixed, obviously also fix the deallocator.
   if (postbuf == NULL) {
     postbuf = new PostDataBuffers();
   }
@@ -1555,6 +1544,7 @@ void
 HttpTunnel::deallocate_redirect_postdata_buffers()
 {
   Debug("http_redirect", "[HttpTunnel::deallocate_postdata_copy_buffers]");
+
   if (postbuf != NULL) {
     if (postbuf->postdata_producer_buffer != NULL) {
       free_MIOBuffer(postbuf->postdata_producer_buffer);

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.h?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.h (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTunnel.h Tue Nov 30 01:42:55 2010
@@ -122,7 +122,8 @@ struct ChunkedHandler
   int running_sum;
   int num_digits;
 
-    ChunkedHandler();
+  ChunkedHandler();
+
   void init(IOBufferReader * buffer_in, HttpTunnelProducer * p);
 
   // Returns true if complete, false otherwise
@@ -195,12 +196,10 @@ struct HttpTunnelProducer
 class PostDataBuffers
 {
 public:
-  PostDataBuffers():postdata_producer_buffer(NULL), postdata_copy_buffer(NULL), postdata_producer_reader(NULL),
-    postdata_copy_buffer_start(NULL), ua_buffer_reader(NULL)
-  {
-    Debug("http_redirect", "[PostDataBuffers::PostDataBuffers]");
-  }
-
+  PostDataBuffers()
+    : postdata_producer_buffer(NULL), postdata_copy_buffer(NULL), postdata_producer_reader(NULL),
+      postdata_copy_buffer_start(NULL), ua_buffer_reader(NULL)
+  { Debug("http_redirect", "[PostDataBuffers::PostDataBuffers]");  }
 
   MIOBuffer *postdata_producer_buffer;
   MIOBuffer *postdata_copy_buffer;
@@ -214,15 +213,12 @@ class HttpTunnel:public Continuation
   friend class HttpPagesHandler;
   friend class CoreUtils;
 public:
-    HttpTunnel();
+  HttpTunnel();
 
   void init(HttpSM * sm_arg, ProxyMutex * amutex);
   void reset();
   void kill_tunnel();
-  bool is_tunnel_active()
-  {
-    return active;
-  };
+  bool is_tunnel_active() { return active; }
   bool is_tunnel_alive();
   bool is_there_cache_write();
 

Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpUpdateSM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpUpdateSM.cc?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpUpdateSM.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpUpdateSM.cc Tue Nov 30 01:42:55 2010
@@ -117,7 +117,7 @@ HttpUpdateSM::handle_api_return()
   }
 
   switch (t_state.next_action) {
-#ifndef INK_NO_TRANSFORM
+#ifndef TS_NO_TRANSFORM
   case HttpTransact::TRANSFORM_READ:
     {
       if (t_state.cache_info.transform_action == HttpTransact::CACHE_DO_WRITE) {
@@ -155,7 +155,7 @@ HttpUpdateSM::handle_api_return()
       }
       break;
     }
-#endif //INK_NO_TRANSFORM
+#endif //TS_NO_TRANSFORM
   case HttpTransact::PROXY_INTERNAL_CACHE_WRITE:
   case HttpTransact::SERVER_READ:
   case HttpTransact::PROXY_INTERNAL_CACHE_NOOP:

Modified: trafficserver/traffic/branches/wccp/proxy/http2/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/Makefile.am?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/Makefile.am (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/Makefile.am Tue Nov 30 01:42:55 2010
@@ -70,5 +70,8 @@ libhttp_a_SOURCES = \
   HttpTunnel.cc \
   HttpTunnel.h \
   HttpUpdateSM.cc \
-  HttpUpdateSM.h \
-  HttpUpdateTester.cc
+  HttpUpdateSM.h
+
+if BUILD_TESTS
+  libhttp_a_SOURCES += HttpUpdateTester.cc
+endif

Propchange: trafficserver/traffic/branches/wccp/proxy/http2/remap/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 30 01:42:55 2010
@@ -0,0 +1,4 @@
+Makefile.in
+Makefile
+libhttp_remap.a
+.deps

Modified: trafficserver/traffic/branches/wccp/proxy/http2/remap/RemapPlugins.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/remap/RemapPlugins.cc?rev=1040383&r1=1040382&r2=1040383&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/remap/RemapPlugins.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/remap/RemapPlugins.cc Tue Nov 30 01:42:55 2010
@@ -328,8 +328,12 @@ RemapPlugins::run_single_remap()
     _request_url->host_set(toHost, toHostLen);
   }
 
-  if (!plugin_modified_port)
-    _request_url->port_set(map_to->port_get_raw());
+  if (!plugin_modified_port) { // Only explicitly set the port if it's not the canonicalized port
+    int to_port = map_to->port_get_raw();
+
+    if (to_port != _request_url->port_get_raw())
+      _request_url->port_set(to_port);
+  }
 
   // Extra byte is potentially needed for prefix path '/'.
   // Added an extra 3 so that TS wouldn't crash in the field.
@@ -362,7 +366,6 @@ RemapPlugins::run_single_remap()
     // requestPathLen,fromPathLen,toPathLen are all 0; in this case, we never
     // initialize newPath, but still de-ref it in *newPath == '/' comparison.
     // The memset fixes that problem.
-
     if (toPath) {
       memcpy(newPath, toPath, toPathLen);
       newPathLen += toPathLen;