| /* | |
| Licensed to the Apache Software Foundation (ASF) under one | |
| or more contributor license agreements. See the NOTICE file | |
| distributed with this work for additional information | |
| regarding copyright ownership. The ASF licenses this file | |
| to you under the Apache License, Version 2.0 (the | |
| "License"); you may not use this file except in compliance | |
| with the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software | |
| distributed under the License is distributed on an "AS IS" BASIS, | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| See the License for the specific language governing permissions and | |
| limitations under the License. | |
| */ | |
| #include "iocore/eventsystem/EventSystem.h" | |
| #undef Status // Major namespace conflict here with tscore/Diags.h::Status | |
| #undef Error | |
| #include "cripts/Lulu.hpp" | |
| #include "cripts/Context.hpp" | |
| // Freelist management. These are here to avoid polluting the Context includes with ATS core includes. | |
| ClassAllocator<cripts::Context> criptContextAllocator("cripts::Context"); | |
| namespace cripts | |
| { | |
| void | |
| Context::reset() | |
| { | |
| // Clear the initialized headers before calling next hook | |
| // Note: we don't clear the pristine URL, nor the Remap From/To URLs, they are static. | |
| if (_client.response.Initialized()) { | |
| _client.response.Reset(); | |
| } | |
| if (_server.response.Initialized()) { | |
| _server.response.Reset(); | |
| } | |
| // Reset the client URL (releases its handle only when we own it). | |
| if (_urls.request.Initialized()) { | |
| _urls.request.Reset(); | |
| } | |
| if (_client.request.Initialized()) { | |
| _client.request.Reset(); | |
| } | |
| if (_server.request.Initialized()) { | |
| _server.request.Reset(); | |
| } | |
| // Release lazy URLs entirely — they get recreated on demand for the next txn. | |
| _urls.pristine.reset(); | |
| _urls.parent.reset(); | |
| _urls.remap.from.reset(); | |
| _urls.remap.to.reset(); | |
| if (_cache.url.Initialized()) { | |
| _cache.url.Reset(); | |
| } | |
| } | |
| Context * | |
| Context::Factory(TSHttpTxn txn_ptr, TSHttpSsn ssn_ptr, TSRemapRequestInfo *rri_ptr, cripts::Instance &inst) | |
| { | |
| return THREAD_ALLOC(criptContextAllocator, this_thread(), txn_ptr, ssn_ptr, rri_ptr, inst); | |
| } | |
| void | |
| Context::Release() | |
| { | |
| reset(); // Clear mloc handles before freeing | |
| THREAD_FREE(this, criptContextAllocator, this_thread()); | |
| } | |
| } // namespace cripts |