atscppapi  1.0.9
C++ wrapper for Apache Traffic Server API
 All Classes Files Functions Enumerations Enumerator Macros
utils_internal.h
1 /*
2  * Copyright (c) 2013 LinkedIn Corp. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of the license at
5  * http://www.apache.org/licenses/LICENSE-2.0
6  *
7  * Unless required by applicable law or agreed to in writing, software distributed under the
8  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9  * either express or implied.
10  *
11  */
12 
13 /**
14  * @file atsutils.h
15  *
16  * @author Brian Geffon
17  * @author Manjesh Nilange
18  *
19  * @brief internal utilities for atscppapi
20  */
21 
22 #pragma once
23 #ifndef ATSCPPAPI_ATSUTILS_H_
24 #define ATSCPPAPI_ATSUTILS_H_
25 
26 #include <ts/ts.h>
27 #include <string>
28 #include "atscppapi/GlobalPlugin.h"
31 #include "atscppapi/Plugin.h"
32 #include "atscppapi/HttpVersion.h"
33 #include "atscppapi/utils.h"
35 #include "atscppapi/Transaction.h"
36 
37 namespace atscppapi {
38 
39 namespace utils {
40 
41 /**
42  * @private
43  */
44 class internal {
45 public:
46  static TSHttpHookID convertInternalHookToTsHook(Plugin::HookType);
47  static TSHttpHookID convertInternalTransformationTypeToTsHook(TransformationPlugin::Type type);
48  static void invokePluginForEvent(TransactionPlugin *, TSHttpTxn, TSEvent);
49  static void invokePluginForEvent(GlobalPlugin *, TSHttpTxn, TSEvent);
50  static HttpVersion getHttpVersion(TSMBuffer hdr_buf, TSMLoc hdr_loc);
51  static void initTransactionManagement();
52  static std::string consumeFromTSIOBufferReader(TSIOBufferReader);
53  static shared_ptr<Mutex> getTransactionPluginMutex(TransactionPlugin &);
54  static Transaction &getTransaction(TSHttpTxn);
55 
56  static AsyncHttpFetchState *getAsyncHttpFetchState(AsyncHttpFetch &async_http_fetch) {
57  return async_http_fetch.state_;
58  }
59 
60  static void initResponse(Response &response, TSMBuffer hdr_buf, TSMLoc hdr_loc) {
61  response.init(hdr_buf, hdr_loc);
62  }
63 
64  static void initTransactionServerRequest(Transaction &transaction) {
65  transaction.initServerRequest();
66  }
67 
68  static void initTransactionServerResponse(Transaction &transaction) {
69  transaction.initServerResponse();
70  }
71 
72  static void initTransactionClientResponse(Transaction &transaction) {
73  transaction.initClientResponse();
74  }
75 
76  static const std::list<TransactionPlugin *> &getTransactionPlugins(const Transaction &transaction) {
77  return transaction.getPlugins();
78  }
79 }; /* internal */
80 
81 } /* utils */
82 
83 }
84 
85 #endif /* ATSCPPAPI_ATSUTILS_H_ */