MCPcopy Create free account
hub / github.com/apache/trafficserver / HandleCacheOpenReadMiss

Method HandleCacheOpenReadMiss

src/proxy/http/HttpTransact.cc:3267–3351  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Name : HandleCacheOpenReadMiss Description: cache looked up, miss or hit, but needs authorization Details : Possible Next States From Here: - HttpTransact::SM_ACTION_DNS_LOOKUP; - HttpTransact::ORIGIN_SERVER_OPEN; - HttpTransact::PROXY_INTERNAL_CACHE_NOOP; - result of how_to_open_connection() /////////////////

Source from the content-addressed store, hash-verified

3265//
3266///////////////////////////////////////////////////////////////////////////////
3267void
3268HttpTransact::HandleCacheOpenReadMiss(State *s)
3269{
3270 TxnDbg(dbg_ctl_http_trans, "--- MISS");
3271 TxnDbg(dbg_ctl_http_seq, "Miss in cache");
3272
3273 if (delete_all_document_alternates_and_return(s, false)) {
3274 TxnDbg(dbg_ctl_http_trans, "Delete and return");
3275 s->cache_info.action = CACHE_DO_NO_ACTION;
3276 s->next_action = SM_ACTION_INTERNAL_CACHE_NOOP;
3277 return;
3278 }
3279 // reinitialize some variables to reflect cache miss state.
3280 s->cache_info.object_read = nullptr;
3281 s->request_sent_time = UNDEFINED_TIME;
3282 s->response_received_time = UNDEFINED_TIME;
3283 SET_VIA_STRING(VIA_CACHE_RESULT, VIA_CACHE_MISS);
3284 if (GET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP) == ' ') {
3285 SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_NOT_CACHED);
3286 }
3287 // We do a cache lookup for some non-GET requests as well.
3288 // We must, however, not cache the responses to these requests.
3289 if (does_method_require_cache_copy_deletion(s->txn_conf, s->method) && s->api_req_cacheable == false) {
3290 s->cache_info.action = CACHE_DO_NO_ACTION;
3291 } else if ((s->hdr_info.client_request.presence(MIME_PRESENCE_RANGE) && !s->txn_conf->cache_range_write) ||
3292 does_method_effect_cache(s->method) == false || s->range_setup == RANGE_NOT_SATISFIABLE ||
3293 s->range_setup == RANGE_NOT_HANDLED) {
3294 s->cache_info.action = CACHE_DO_NO_ACTION;
3295 } else if (s->api_server_response_no_store) { // plugin may have decided not to cache the response
3296 s->cache_info.action = CACHE_DO_NO_ACTION;
3297 } else {
3298 HttpTransact::set_cache_prepare_write_action_for_new_request(s);
3299 }
3300
3301 ///////////////////////////////////////////////////////////////
3302 // a normal miss would try to fetch the document from the //
3303 // origin server, unless the origin server isn't resolvable, //
3304 // but if "CacheControl: only-if-cached" is set, then we are //
3305 // supposed to send a 504 (GATEWAY TIMEOUT) response. //
3306 ///////////////////////////////////////////////////////////////
3307
3308 HTTPHdr *h = &s->hdr_info.client_request;
3309
3310 if (!h->is_cache_control_set(HTTP_VALUE_ONLY_IF_CACHED)) {
3311 // Initialize the server_info structure if we haven't been through DNS
3312 // Otherwise, the http_version will not be initialized
3313 if (!s->current.server || !s->current.server->dst_addr.isValid()) {
3314 // Short term hack. get_ka_info_from_config assumes if http_version is > 0,9 it has already been
3315 // set and skips the rest of the function. The default functor sets it to 1,0
3316 s->server_info.http_version = HTTP_0_9;
3317 get_ka_info_from_config(s, &s->server_info);
3318 }
3319 find_server_and_update_current_info(s);
3320 // a parent lookup could come back as PARENT_FAIL if in parent.config go_direct == false and
3321 // there are no available parents (all down).
3322 if (s->parent_result.result == PARENT_FAIL) {
3323 handle_parent_down(s);
3324 return;

Callers

nothing calls this directly

Calls 9

does_method_effect_cacheFunction · 0.85
build_requestFunction · 0.85
how_to_open_connectionFunction · 0.85
presenceMethod · 0.80
is_cache_control_setMethod · 0.80
isValidMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected