| /* |
| 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 <cripts/Preamble.hpp> |
| |
| do_remap() |
| { |
| borrow url = cripts::Client::URL::Get(); |
| |
| // Force the live Query / Path to parse so _state is populated; otherwise the |
| // copies below take the nullptr branch and the deep-copy logic isn't exercised. |
| url.query["foo"]; |
| url.path[0]; |
| |
| // Copy-construct to exercise the explicit copy ctor (each owns a std::unique_ptr<State>). |
| // Note: this remains tied to the same underlying URL; it is not an independent snapshot. |
| cripts::Url::Query query_copy = url.query; |
| cripts::Url::Query query_assigned; |
| cripts::Url::Path path_copy = url.path; |
| cripts::Url::Path path_assigned; |
| |
| query_assigned = url.query; |
| path_assigned = url.path; |
| |
| query_copy.Erase("foo"); |
| path_copy[0] = "edited"; |
| |
| // Materialize into owned strings so do_send_response sees stable values. |
| txn_data[0] = cripts::string(url.query.GetSV()); |
| txn_data[1] = cripts::string(query_copy.GetSV()); |
| txn_data[2] = cripts::string(query_assigned.GetSV()); |
| txn_data[3] = cripts::string(url.path.GetSV()); |
| txn_data[4] = cripts::string(path_copy.GetSV()); |
| txn_data[5] = cripts::string(path_assigned.GetSV()); |
| } |
| |
| do_send_response() |
| { |
| borrow resp = cripts::Client::Response::Get(); |
| |
| resp["X-Original-Query"] = AsString(txn_data[0]); |
| resp["X-Copy-Query"] = AsString(txn_data[1]); |
| resp["X-Assigned-Query"] = AsString(txn_data[2]); |
| resp["X-Original-Path"] = AsString(txn_data[3]); |
| resp["X-Copy-Path"] = AsString(txn_data[4]); |
| resp["X-Assigned-Path"] = AsString(txn_data[5]); |
| } |
| |
| #include <cripts/Epilogue.hpp> |