You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ni...@apache.org on 2012/01/16 22:51:51 UTC

svn commit: r1232180 - in /trafficserver/traffic/trunk/proxy: InkAPI.cc api/ts/ts.h.in hdrs/HTTP.cc hdrs/URL.h

Author: niq
Date: Mon Jan 16 21:51:50 2012
New Revision: 1232180

URL: http://svn.apache.org/viewvc?rev=1232180&view=rev
Log:
TS-998
Keep a record of the original Request on the URLImpl
and provide a new API to access it.
Should be cheap: copying is only required if copy_strings is true in url_parse.

Modified:
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
    trafficserver/traffic/trunk/proxy/hdrs/HTTP.cc
    trafficserver/traffic/trunk/proxy/hdrs/URL.h

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1232180&r1=1232179&r2=1232180&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Mon Jan 16 21:51:50 2012
@@ -4538,6 +4538,20 @@ TSHttpTxnClientKeepaliveSet(TSHttpTxn tx
 
   s->hdr_info.trust_response_cl = (set != 0) ? true : false;
 }
+TSReturnCode
+TSHttpTxnClientDataGet(TSHttpTxn txnp, const char **bufp, int *len)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+  
+  HttpSM *sm = (HttpSM *) txnp;
+  HTTPHdr *hptr = &(sm->t_state.hdr_info.client_request);
+  if (hptr->valid()) {
+    *bufp = hptr->m_url_cached.m_url_impl->the_request;
+    *len = hptr->m_url_cached.m_url_impl->the_request_len;
+    return TS_SUCCESS;
+  }
+  return TS_ERROR;
+}
 
 TSReturnCode
 TSHttpTxnClientReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)

Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h.in?rev=1232180&r1=1232179&r2=1232180&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h.in (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h.in Mon Jan 16 21:51:50 2012
@@ -2162,6 +2162,8 @@ extern "C"
   tsapi TSHttpSsn TSHttpTxnSsnGet(TSHttpTxn txnp);
   tsapi TSReturnCode TSHttpTxnClientReqGet(TSHttpTxn txnp, TSMBuffer* bufp, TSMLoc* offset);
   tsapi TSReturnCode TSHttpTxnPristineUrlGet(TSHttpTxn txnp, TSMBuffer* bufp, TSMLoc* url_loc);
+  /* Get the request headers as sent by the Client */
+  tsapi TSReturnCode TSHttpTxnClientDataGet(TSHttpTxn txnp, const char **bufp, int *len);
   /** Get the effective URL for the transaction.
       The effective URL is the URL taking in to account both the explicit
       URL in the request and the HOST field.

Modified: trafficserver/traffic/trunk/proxy/hdrs/HTTP.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/HTTP.cc?rev=1232180&r1=1232179&r2=1232180&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/HTTP.cc (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/HTTP.cc Mon Jan 16 21:51:50 2012
@@ -913,6 +913,11 @@ http_parser_parse_req(HTTPParser *parser
     cur = line_start;
     must_copy_strings = (must_copy_strings || (!line_is_real));
 
+    mime_str_u16_set(heap, line_start, strlen(line_start),
+                     &(hh->u.req.m_url_impl->the_request),
+                     &(hh->u.req.m_url_impl->the_request_len),
+                     must_copy_strings);
+
 #if (ENABLE_PARSER_FAST_PATHS)
     // first try fast path
     if (end - cur >= 16) {

Modified: trafficserver/traffic/trunk/proxy/hdrs/URL.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/URL.h?rev=1232180&r1=1232179&r2=1232180&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/URL.h (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/URL.h Mon Jan 16 21:51:50 2012
@@ -83,6 +83,10 @@ struct URLImpl:public HdrHeapObjImpl
 
   // Sanity Check Functions
   void check_strings(HeapCheck *heaps, int num_heaps);
+
+  // The original (unparsed) request
+  const char *the_request;
+  uint16_t the_request_len;
 };