1 /** @file
2 
3   A brief file description
4 
5   @section license License
6 
7   Licensed to the Apache Software Foundation (ASF) under one
8   or more contributor license agreements.  See the NOTICE file
9   distributed with this work for additional information
10   regarding copyright ownership.  The ASF licenses this file
11   to you under the Apache License, Version 2.0 (the
12   "License"); you may not use this file except in compliance
13   with the License.  You may obtain a copy of the License at
14 
15       http://www.apache.org/licenses/LICENSE-2.0
16 
17   Unless required by applicable law or agreed to in writing, software
18   distributed under the License is distributed on an "AS IS" BASIS,
19   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   See the License for the specific language governing permissions and
21   limitations under the License.
22  */
23 
24 /****************************************************************************
25 
26    HttpPages.h
27 
28    Description:
29        Data structures and stat page generators for http info
30 
31 
32  ****************************************************************************/
33 
34 #pragma once
35 
36 #include "tscore/ink_platform.h"
37 #include "P_EventSystem.h"
38 #include "HTTP.h"
39 #include "StatPages.h"
40 #include "HttpSM.h"
41 
42 class HttpSM;
43 
44 const int HTTP_LIST_BUCKETS = 63;
45 const int HTTP_LIST_RETRY   = HRTIME_MSECONDS(10);
46 
47 struct HttpSMListBucket {
48   Ptr<ProxyMutex> mutex;
49   DList(HttpSM, debug_link) sm_list;
50 };
51 
52 extern HttpSMListBucket HttpSMList[];
53 
54 class HttpPagesHandler : public BaseStatPagesHandler
55 {
56 public:
57   HttpPagesHandler(Continuation *cont, HTTPHdr *header);
58   ~HttpPagesHandler() override;
59 
60   int handle_smlist(int event, void *edata);
61   int handle_smdetails(int event, void *edata);
62   int handle_callback(int event, void *edata);
63   Action action;
64 
65 private:
66   int64_t extract_id(const char *query);
67   void dump_hdr(HTTPHdr *hdr, const char *desc);
68   void dump_tunnel_info(HttpSM *sm);
69   void dump_history(HttpSM *sm);
70   int dump_sm(HttpSM *sm);
71 
72   Arena arena;
73   char *request;
74   int list_bucket;
75 
76   enum HP_State_t {
77     HP_INIT,
78     HP_RUN,
79   };
80   HP_State_t state;
81 
82   // Info for SM details
83   int64_t sm_id;
84 };
85 
86 void http_pages_init();
87