trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject [1/2] git commit: atscppapi: fix for TS-2777 - using content length from correct header
Date Mon, 05 May 2014 18:46:16 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master 5da3a4b90 -> 24a5ee5dd


atscppapi: fix for TS-2777 - using content length from correct header


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

Branch: refs/heads/master
Commit: 4bd8af16ae8fb0ef99988798dc00289af2c30156
Parents: cf22df8
Author: Manjesh Nilange <manjeshnilange@yahoo.com>
Authored: Fri May 2 10:42:07 2014 -0700
Committer: Manjesh Nilange <manjeshnilange@yahoo.com>
Committed: Fri May 2 10:42:07 2014 -0700

----------------------------------------------------------------------
 lib/atscppapi/src/InterceptPlugin.cc | 39 +++++++++++++++----------------
 1 file changed, 19 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4bd8af16/lib/atscppapi/src/InterceptPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/InterceptPlugin.cc b/lib/atscppapi/src/InterceptPlugin.cc
index cac8f0b..0e7ca13 100644
--- a/lib/atscppapi/src/InterceptPlugin.cc
+++ b/lib/atscppapi/src/InterceptPlugin.cc
@@ -123,26 +123,6 @@ InterceptPlugin::InterceptPlugin(Transaction &transaction, InterceptPlugin::Type
   else {
     TSHttpTxnIntercept(cont, txn);
   }
-  Headers &request_headers = transaction.getClientRequest().getHeaders();
-  string content_length_str = request_headers.value("Content-Length");
-  if (!content_length_str.empty()) {
-    const char *start_ptr = content_length_str.data();
-    char *end_ptr;
-    int content_length = strtol(start_ptr, &end_ptr, 10 /* base */);
-    if ((errno != ERANGE) && (end_ptr != start_ptr) && (*end_ptr == '\0'))
{
-      LOG_DEBUG("Got content length: %d", content_length);
-      state_->expected_body_size_ = content_length;
-    }
-    else {
-      LOG_ERROR("Invalid content length header [%s]; Assuming no content", content_length_str.c_str());
-    }
-  }
-  if (request_headers.value("Transfer-Encoding") == "chunked") {
-    // implementing a "dechunker" is non-trivial and in the real
-    // world, most browsers don't send chunked requests
-    LOG_ERROR("Support for chunked request not implemented! Assuming no body");
-  }
-  LOG_DEBUG("Expecting %d bytes of request body", state_->expected_body_size_);
 }
 
 InterceptPlugin::~InterceptPlugin() {
@@ -223,6 +203,25 @@ bool InterceptPlugin::doRead() {
         if (TSHttpHdrParseReq(state_->http_parser_, state_->hdr_buf_, state_->hdr_loc_,
&data,
                               endptr) == TS_PARSE_DONE) {
           LOG_DEBUG("Parsed header");
+          string content_length_str = state_->request_headers_.value("Content-Length");
+          if (!content_length_str.empty()) {
+            const char *start_ptr = content_length_str.data();
+            char *end_ptr;
+            int content_length = strtol(start_ptr, &end_ptr, 10 /* base */);
+            if ((errno != ERANGE) && (end_ptr != start_ptr) && (*end_ptr
== '\0')) {
+              LOG_DEBUG("Got content length: %d", content_length);
+              state_->expected_body_size_ = content_length;
+            }
+            else {
+              LOG_ERROR("Invalid content length header [%s]; Assuming no content", content_length_str.c_str());
+            }
+          }
+          if (state_->request_headers_.value("Transfer-Encoding") == "chunked") {
+            // implementing a "dechunker" is non-trivial and in the real
+            // world, most browsers don't send chunked requests
+            LOG_ERROR("Support for chunked request not implemented! Assuming no body");
+          }
+          LOG_DEBUG("Expecting %d bytes of request body", state_->expected_body_size_);
           state_->hdr_parsed_ = true;
           // remaining data in this block is body; 'data' will be pointing to first byte
of the body
           num_body_bytes_in_block = endptr - data;


Mime
View raw message