You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2010/09/10 20:23:53 UTC

svn commit: r995921 - in /trafficserver/traffic/trunk/proxy: InkAPI.cc api/ts/ts.h http2/HttpTransact.cc http2/HttpTransact.h

Author: bcall
Date: Fri Sep 10 18:23:52 2010
New Revision: 995921

URL: http://svn.apache.org/viewvc?rev=995921&view=rev
Log:
TS-395 Added APIs to override the cacheablity of the response.
Original author: Vijay
Patch created and updated: Bryan Call

Modified:
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/api/ts/ts.h
    trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc
    trafficserver/traffic/trunk/proxy/http2/HttpTransact.h

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=995921&r1=995920&r2=995921&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Fri Sep 10 18:23:52 2010
@@ -5795,6 +5795,20 @@ INKHttpTxnAborted(INKHttpTxn txnp)
   return 0;
 }
 
+void
+INKHttpTxnSetReqCacheableSet(INKHttpTxn txnp)
+{
+  HttpSM* sm = (HttpSM*)txnp;
+  sm->t_state.api_req_cacheable = true;
+}
+
+void
+INKHttpTxnSetRespCacheableSet(INKHttpTxn txnp)
+{
+  HttpSM* sm = (HttpSM*)txnp;
+  sm->t_state.api_resp_cacheable = true;
+}
+
 int
 INKHttpTxnClientReqIsServerStyle(INKHttpTxn txnp)
 {

Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h?rev=995921&r1=995920&r2=995921&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h Fri Sep 10 18:23:52 2010
@@ -1963,8 +1963,10 @@ extern "C"
   inkapi int INKHttpTxnServerRespGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * offset);
   inkapi int INKHttpTxnCachedReqGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * offset);
   inkapi int INKHttpTxnCachedRespGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * offset);
-  inkapi int               INKFetchPageRespGet (INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *offset);
-  inkapi char*               INKFetchRespGet (INKHttpTxn txnp, int *length);
+  inkapi void INKHttpTxnSetRespCacheableSet(INKHttpTxn txnp);
+  inkapi void INKHttpTxnSetReqCacheableSet(INKHttpTxn txnp);
+  inkapi int INKFetchPageRespGet (INKHttpTxn txnp, INKMBuffer *bufp, INKMLoc *offset);
+  inkapi char* INKFetchRespGet (INKHttpTxn txnp, int *length);
   inkapi INKReturnCode INKHttpTxnCacheLookupStatusGet(INKHttpTxn txnp, int *lookup_status);
 
   inkapi int INKHttpTxnTransformRespGet(INKHttpTxn txnp, INKMBuffer * bufp, INKMLoc * offset);

Modified: trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc?rev=995921&r1=995920&r2=995921&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc Fri Sep 10 18:23:52 2010
@@ -2930,7 +2930,7 @@ HttpTransact::build_response_from_cache(
     // fall through
   default:
     SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_HIT_SERVED);
-    if (s->method == HTTP_WKSIDX_GET) {
+    if (s->method == HTTP_WKSIDX_GET || s->api_resp_cacheable == true) {
 
       // send back the full document to the client.
       Debug("http_trans", "[build_response_from_cache] Match! Serving full document.");
@@ -3145,7 +3145,7 @@ HttpTransact::HandleCacheOpenReadMiss(St
   }
   // We do a cache lookup for DELETE and PUT requests as well.
   // We must, however, not cache the responses to these requests.
-  if (does_method_require_cache_copy_deletion(s->method)) {
+  if (does_method_require_cache_copy_deletion(s->method) && s->api_req_cacheable == false) {
     s->cache_info.action = CACHE_DO_NO_ACTION;
   } else if (s->range_setup == RANGE_NOT_SATISFIABLE || s->range_setup == RANGE_NOT_HANDLED) {
     s->cache_info.action = CACHE_DO_NO_ACTION;
@@ -6238,7 +6238,7 @@ HttpTransact::is_cache_response_returnab
     return false;
   }
 
-  if (!HttpTransactHeaders::is_method_cacheable(s->method)) {
+  if (!HttpTransactHeaders::is_method_cacheable(s->method) && s->api_resp_cacheable == false) {
     SET_VIA_STRING(VIA_CACHE_RESULT, VIA_IN_CACHE_NOT_ACCEPTABLE);
     SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_METHOD);
     return false;
@@ -6403,7 +6403,7 @@ HttpTransact::is_request_cache_lookupabl
     return false;
   }
   // GET, HEAD, POST, DELETE, and PUT are all cache lookupable
-  if (!HttpTransactHeaders::is_method_cache_lookupable(s->method)) {
+  if (!HttpTransactHeaders::is_method_cache_lookupable(s->method) && s->api_req_cacheable == false) {
     SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_METHOD);
     return false;
   }
@@ -6510,7 +6510,7 @@ HttpTransact::is_response_cacheable(Stat
   // Basically, the problem is the resp for POST url1 req should not
   // be served to a GET url1 request, but we just match URL not method.
   int req_method = request->method_get_wksidx();
-  if (!(HttpTransactHeaders::is_method_cacheable(req_method))) {
+  if (!(HttpTransactHeaders::is_method_cacheable(req_method)) && s->api_req_cacheable == false) {
     Debug("http_trans", "[is_response_cacheable] " "only GET, and some HEAD and POST are cachable");
     return (false);
   }
@@ -8257,7 +8257,7 @@ HttpTransact::handle_server_died(State *
 bool
 HttpTransact::is_request_likely_cacheable(State * s, HTTPHdr * request)
 {
-  if ((s->method == HTTP_WKSIDX_GET) && !request->presence(MIME_PRESENCE_AUTHORIZATION)) {
+  if ((s->method == HTTP_WKSIDX_GET || s->api_req_cacheable == true) && !request->presence(MIME_PRESENCE_AUTHORIZATION)) {
     return true;
   }
   return false;

Modified: trafficserver/traffic/trunk/proxy/http2/HttpTransact.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/HttpTransact.h?rev=995921&r1=995920&r2=995921&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/HttpTransact.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/HttpTransact.h Fri Sep 10 18:23:52 2010
@@ -1070,6 +1070,8 @@ public:
     bool api_http_sm_shutdown;
     bool api_modifiable_cached_resp;
     bool api_server_request_body_set;
+    bool api_req_cacheable;
+    bool api_resp_cacheable;
     UpdateCachedObject_t api_update_cached_object;
     LockUrl_t api_lock_url;
     StateMachineAction_t saved_update_next_action;
@@ -1391,6 +1393,8 @@ api_server_response_ignore(false),
 api_http_sm_shutdown(false),
 api_modifiable_cached_resp(false),
 api_server_request_body_set(false),
+api_req_cacheable(false),
+api_resp_cacheable(false),
 api_update_cached_object(UPDATE_CACHED_OBJECT_NONE),
 api_lock_url(LOCK_URL_FIRST),
 saved_update_next_action(STATE_MACHINE_ACTION_UNDEFINED),