blob: bebc6ba7d269f4a5aeb3e6a204678ec7bc3656ad [file]
/*
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.
*/
// Sets the same kinds of dynamic header values as bundle_headers.cript but
// via the direct cripts API (UUID/IP/Url accessors), without going through
// cripts::Bundle::Headers / HRWBridge. Pairs with the bundle test to give
// coverage of both header-substitution code paths.
#include <cripts/Preamble.hpp>
do_remap()
{
borrow req = cripts::Client::Request::Get();
borrow url = cripts::Client::URL::Get();
borrow conn = cripts::Client::Connection::Get();
auto ip = conn.IP();
req["X-Direct-Req-UUID"] = cripts::UUID::Unique::_get(context);
req["X-Direct-Req-Host"] = url.host;
req["X-Direct-Req-Path"] = url.path;
req["X-Direct-Req-Query"] = url.query;
req["X-Direct-Req-Scheme"] = url.scheme;
req["X-Direct-Req-Port"] = url.port; // integer overload
req["X-Direct-Req-CIP"] = ip.string();
}
do_send_request()
{
borrow sreq = cripts::Server::Request::Get();
borrow url = cripts::Client::URL::Get();
sreq["X-Direct-SReq-UUID"] = cripts::UUID::Unique::_get(context);
sreq["X-Direct-SReq-Path"] = url.path;
}
do_send_response()
{
borrow resp = cripts::Client::Response::Get();
borrow url = cripts::Client::URL::Get();
borrow conn = cripts::Client::Connection::Get();
auto ip = conn.IP();
resp["X-Direct-Resp-UUID"] = cripts::UUID::Unique::_get(context);
resp["X-Direct-Resp-ProcID"] = cripts::UUID::Process::_get(context);
resp["X-Direct-Resp-Host"] = url.host;
resp["X-Direct-Resp-Path"] = url.path;
resp["X-Direct-Resp-CIP"] = ip.string();
}
#include <cripts/Epilogue.hpp>