You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2015/06/16 21:37:35 UTC

[1/2] trafficserver git commit: TS-3656: Activating follow redirection in send server response hook does not work for post. This closes #215.

Repository: trafficserver
Updated Branches:
  refs/heads/master 30559536d -> bedbe23dc


TS-3656: Activating follow redirection in send server response hook does not work for post. This closes #215.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/999946e4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/999946e4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/999946e4

Branch: refs/heads/master
Commit: 999946e47a90324ff8bfcbb22d40493e89463599
Parents: 3055953
Author: shinrich <sh...@yahoo-inc.com>
Authored: Tue Jun 16 14:35:14 2015 -0500
Committer: shinrich <sh...@yahoo-inc.com>
Committed: Tue Jun 16 14:35:14 2015 -0500

----------------------------------------------------------------------
 proxy/http/HttpSM.cc     | 34 +++++++++++++++-------------------
 proxy/http/HttpTunnel.cc | 27 +++------------------------
 proxy/http/HttpTunnel.h  |  7 +------
 3 files changed, 19 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999946e4/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 4239dcb..002e5cc 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -1804,14 +1804,6 @@ HttpSM::state_read_server_response_header(int event, void *data)
     t_state.transact_return_point = HttpTransact::HandleResponse;
     t_state.api_next_action = HttpTransact::SM_ACTION_API_READ_RESPONSE_HDR;
 
-    // if exceeded limit deallocate postdata buffers and disable redirection
-    if (enable_redirection && (redirection_tries < HttpConfig::m_master.number_of_redirections)) {
-      ++redirection_tries;
-    } else {
-      tunnel.deallocate_redirect_postdata_buffers();
-      enable_redirection = false;
-    }
-
     do_api_callout();
     break;
   case PARSE_CONT:
@@ -3151,7 +3143,6 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer *c)
   ink_assert(ua_entry->vc == c->vc);
   if (close_connection) {
     // If the client could be pipelining, we need to set the ua_session into half close mode
-
     if (t_state.client_info.pipeline_possible == true && c->producer->vc_type != HT_STATIC && event == VC_EVENT_WRITE_COMPLETE) {
       ua_session->set_half_close_flag();
     }
@@ -3401,8 +3392,6 @@ HttpSM::tunnel_handler_for_partial_post(int event, void * /* data ATS_UNUSED */)
   tunnel.deallocate_buffers();
   tunnel.reset();
 
-  tunnel.allocate_redirect_postdata_producer_buffer();
-
   t_state.redirect_info.redirect_in_process = false;
 
   if (post_failed) {
@@ -5312,17 +5301,20 @@ HttpSM::do_setup_post_tunnel(HttpVC_t to_vc_type)
   // if redirect_in_process and redirection is enabled add static producer
 
   if (t_state.redirect_info.redirect_in_process && enable_redirection &&
-      (tunnel.postbuf && tunnel.postbuf->postdata_copy_buffer_start != NULL && tunnel.postbuf->postdata_producer_buffer != NULL)) {
+      (tunnel.postbuf && tunnel.postbuf->postdata_copy_buffer_start != NULL)) {
     post_redirect = true;
     // copy the post data into a new producer buffer for static producer
-    tunnel.postbuf->postdata_producer_buffer->write(tunnel.postbuf->postdata_copy_buffer_start);
-    int64_t post_bytes = tunnel.postbuf->postdata_producer_reader->read_avail();
+    int64_t alloc_index = buffer_size_to_index(t_state.hdr_info.request_content_length);
+    MIOBuffer *postdata_producer_buffer = new_MIOBuffer(alloc_index);
+    IOBufferReader *postdata_producer_reader = postdata_producer_buffer->alloc_reader();
+    postdata_producer_buffer->write(tunnel.postbuf->postdata_copy_buffer_start);
+    int64_t post_bytes = postdata_producer_reader->read_avail();
     transfered_bytes = post_bytes;
-    p = tunnel.add_producer(HTTP_TUNNEL_STATIC_PRODUCER, post_bytes, tunnel.postbuf->postdata_producer_reader,
-                            (HttpProducerHandler)NULL, HT_STATIC, "redirect static agent post");
+    p = tunnel.add_producer(HTTP_TUNNEL_STATIC_PRODUCER, post_bytes, postdata_producer_reader, (HttpProducerHandler)NULL, HT_STATIC,
+                            "redirect static agent post");
     // the tunnel has taken over the buffer and will free it
-    tunnel.postbuf->postdata_producer_buffer = NULL;
-    tunnel.postbuf->postdata_producer_reader = NULL;
+    postdata_producer_buffer = NULL;
+    postdata_producer_reader = NULL;
   } else {
     int64_t alloc_index;
     // content length is undefined, use default buffer size
@@ -5351,6 +5343,8 @@ HttpSM::do_setup_post_tunnel(HttpVC_t to_vc_type)
     ua_buffer_reader->consume(client_request_body_bytes);
     p = tunnel.add_producer(ua_entry->vc, post_bytes - transfered_bytes, buf_start, &HttpSM::tunnel_handler_post_ua, HT_HTTP_CLIENT,
                             "user agent post");
+    post_buffer = NULL;
+    buf_start = NULL;
   }
   ua_entry->in_tunnel = true;
 
@@ -7296,8 +7290,10 @@ void
 HttpSM::do_redirect()
 {
   DebugSM("http_redirect", "[HttpSM::do_redirect]");
-  if (!enable_redirection || redirection_tries >= HttpConfig::m_master.number_of_redirections) {
+  // if exceeded limit deallocate postdata buffers and disable redirection
+  if (!enable_redirection || (redirection_tries++ >= HttpConfig::m_master.number_of_redirections)) {
     tunnel.deallocate_redirect_postdata_buffers();
+    enable_redirection = false;
     return;
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999946e4/proxy/http/HttpTunnel.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc
index c5eb009..571d512 100644
--- a/proxy/http/HttpTunnel.cc
+++ b/proxy/http/HttpTunnel.cc
@@ -920,9 +920,9 @@ HttpTunnel::producer_run(HttpTunnelProducer *p)
   }
 
   // YTS Team, yamsat Plugin
-  // Allocate and copy partial POST data to buffers. Check for the various parameters
-  // including the maximum configured post data size
-  if (p->alive && sm->t_state.method == HTTP_WKSIDX_POST && sm->enable_redirection && (p->vc_type == HT_HTTP_CLIENT)) {
+  // Allocate and copy partial POST data to buffers for possible later use in redirect.
+  // Check for the various parameters including the maximum configured post data size
+  if (p->alive && sm->t_state.method == HTTP_WKSIDX_POST && (p->vc_type == HT_HTTP_CLIENT)) {
     Debug("http_redirect", "[HttpTunnel::producer_run] client post: %" PRId64 " max size: %" PRId64 "",
           p->buffer_start->read_avail(), HttpConfig::m_master.post_copy_size);
 
@@ -1622,19 +1622,6 @@ HttpTunnel::copy_partial_post_data()
 }
 
 // YTS Team, yamsat Plugin
-// Allocate a new buffer for static producers
-void
-HttpTunnel::allocate_redirect_postdata_producer_buffer()
-{
-  int64_t alloc_index = buffer_size_to_index(sm->t_state.hdr_info.request_content_length);
-
-  ink_release_assert(postbuf->postdata_producer_buffer == NULL);
-
-  postbuf->postdata_producer_buffer = new_MIOBuffer(alloc_index);
-  postbuf->postdata_producer_reader = postbuf->postdata_producer_buffer->alloc_reader();
-}
-
-// YTS Team, yamsat Plugin
 // Allocating the post data buffers
 void
 HttpTunnel::allocate_redirect_postdata_buffers(IOBufferReader *ua_reader)
@@ -1650,13 +1637,10 @@ HttpTunnel::allocate_redirect_postdata_buffers(IOBufferReader *ua_reader)
     postbuf->ua_buffer_reader = ua_reader;
     postbuf->postdata_copy_buffer = new_MIOBuffer(alloc_index);
     postbuf->postdata_copy_buffer_start = postbuf->postdata_copy_buffer->alloc_reader();
-    allocate_redirect_postdata_producer_buffer();
   } else {
     // Reset the buffer readers
     postbuf->postdata_copy_buffer->dealloc_reader(postbuf->postdata_copy_buffer_start);
     postbuf->postdata_copy_buffer_start = postbuf->postdata_copy_buffer->alloc_reader();
-    postbuf->postdata_producer_buffer->dealloc_reader(postbuf->postdata_producer_reader);
-    postbuf->postdata_producer_reader = postbuf->postdata_producer_buffer->alloc_reader();
   }
 }
 
@@ -1669,11 +1653,6 @@ 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);
-      postbuf->postdata_producer_buffer = NULL;
-      postbuf->postdata_producer_reader = NULL; // deallocated by the buffer
-    }
     if (postbuf->postdata_copy_buffer != NULL) {
       free_MIOBuffer(postbuf->postdata_copy_buffer);
       postbuf->postdata_copy_buffer = NULL;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/999946e4/proxy/http/HttpTunnel.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTunnel.h b/proxy/http/HttpTunnel.h
index db760a6..3bfac74 100644
--- a/proxy/http/HttpTunnel.h
+++ b/proxy/http/HttpTunnel.h
@@ -260,16 +260,12 @@ 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)
+  PostDataBuffers() : postdata_copy_buffer(NULL), postdata_copy_buffer_start(NULL), ua_buffer_reader(NULL)
   {
     Debug("http_redirect", "[PostDataBuffers::PostDataBuffers]");
   }
 
-  MIOBuffer *postdata_producer_buffer;
   MIOBuffer *postdata_copy_buffer;
-  IOBufferReader *postdata_producer_reader;
   IOBufferReader *postdata_copy_buffer_start;
   IOBufferReader *ua_buffer_reader;
 };
@@ -314,7 +310,6 @@ public:
 
   // YTS Team, yamsat Plugin
   void copy_partial_post_data();
-  void allocate_redirect_postdata_producer_buffer();
   void allocate_redirect_postdata_buffers(IOBufferReader *ua_reader);
   void deallocate_redirect_postdata_buffers();
 


[2/2] trafficserver git commit: TS-3656: Update changes.

Posted by sh...@apache.org.
TS-3656: Update changes.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/bedbe23d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/bedbe23d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/bedbe23d

Branch: refs/heads/master
Commit: bedbe23dcb5e4fab8cf58608ab45fd52217d79de
Parents: 999946e
Author: shinrich <sh...@yahoo-inc.com>
Authored: Tue Jun 16 14:36:23 2015 -0500
Committer: shinrich <sh...@yahoo-inc.com>
Committed: Tue Jun 16 14:36:23 2015 -0500

----------------------------------------------------------------------
 CHANGES | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bedbe23d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4eb9472..aa68551 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 6.0.0
 
+  *) [TS-3656] Activating follow redirection in send server response hook does not work for post
+
   *) [TS-3541] Eliminate the interim cache feature.
 
   *) [TS-3327] Nuke the support for HTTP/0.9.