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

Method set_headers_for_cache_write

src/proxy/http/HttpTransact.cc:4931–4989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4929}
4930
4931void
4932HttpTransact::set_headers_for_cache_write(State *s, HTTPInfo *cache_info, HTTPHdr *request, HTTPHdr *response)
4933{
4934 URL *temp_url;
4935 ink_assert(request->type_get() == HTTP_TYPE_REQUEST);
4936 ink_assert(response->type_get() == HTTP_TYPE_RESPONSE);
4937
4938 if (!cache_info->valid()) {
4939 cache_info->create();
4940 }
4941
4942 /* Store the requested URI */
4943 // Nasty hack. The set calls for
4944 // marshalled types current do handle something being
4945 // set to itself. Make the check here for that case.
4946 // Why the request url is set before a copy made is
4947 // quite beyond me. Seems like a unsafe practice so
4948 // FIX ME!
4949
4950 // Logic added to restore the original URL for multiple cache lookup
4951 // and automatic redirection
4952 if (s->redirect_info.redirect_in_process) {
4953 temp_url = &s->redirect_info.original_url;
4954 ink_assert(temp_url->valid());
4955 request->url_set(temp_url);
4956 } else if ((temp_url = &(s->cache_info.original_url))->valid()) {
4957 request->url_set(temp_url);
4958 } else if (request != &s->hdr_info.client_request) {
4959 request->url_set(s->hdr_info.client_request.url_get());
4960 }
4961 cache_info->request_set(request);
4962 /* Why do we check the negative caching case? No one knows. This used to assert if the cache_info
4963 response wasn't already valid, which broke negative caching when a transform is active. Why it
4964 wasn't OK to pull in the @a response explicitly passed in isn't clear and looking at the call
4965 sites yields no insight. So the assert is removed and we keep the behavior that if the response
4966 in @a cache_info is already set, we don't override it.
4967 */
4968 if (!s->is_cacheable_due_to_negative_caching_configuration || !cache_info->response_get()->valid()) {
4969 cache_info->response_set(response);
4970 }
4971
4972 if (s->api_server_request_body_set) {
4973 cache_info->request_get()->method_set(HTTP_METHOD_GET, HTTP_LEN_GET);
4974 }
4975
4976 // Set-Cookie should not be put in the cache to prevent
4977 // sending person A's cookie to person B
4978 cache_info->response_get()->field_delete(MIME_FIELD_SET_COOKIE, MIME_LEN_SET_COOKIE);
4979 cache_info->request_get()->field_delete(MIME_FIELD_VIA, MIME_LEN_VIA);
4980 // server 200 Ok for Range request
4981 cache_info->request_get()->field_delete(MIME_FIELD_RANGE, MIME_LEN_RANGE);
4982
4983 // If we're ignoring auth, then we don't want to cache WWW-Auth headers
4984 if (s->txn_conf->cache_ignore_auth) {
4985 cache_info->response_get()->field_delete(MIME_FIELD_WWW_AUTHENTICATE, MIME_LEN_WWW_AUTHENTICATE);
4986 }
4987
4988 dump_header(dbg_ctl_http_hdrs, cache_info->request_get(), s->state_machine_id(), "Cached Request Hdr");

Callers

nothing calls this directly

Calls 13

dump_headerFunction · 0.85
type_getMethod · 0.80
url_getMethod · 0.80
request_setMethod · 0.80
response_getMethod · 0.80
response_setMethod · 0.80
method_setMethod · 0.80
request_getMethod · 0.80
field_deleteMethod · 0.80
state_machine_idMethod · 0.80
validMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected