~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to proxy/TransformInternal.h

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#ifndef __TRANSFORM_INTERNAL_H__
 
25
#define __TRANSFORM_INTERNAL_H__
 
26
 
 
27
 
 
28
#include "HttpSM.h"
 
29
#include "MIME.h"
 
30
#include "Transform.h"
 
31
#include "P_EventSystem.h"
 
32
 
 
33
 
 
34
class TransformVConnection;
 
35
 
 
36
 
 
37
class TransformTerminus:public VConnection
 
38
{
 
39
public:
 
40
  TransformTerminus(TransformVConnection * tvc);
 
41
 
 
42
  int handle_event(int event, void *edata);
 
43
 
 
44
  VIO *do_io_read(Continuation * c, int64_t nbytes, MIOBuffer * buf);
 
45
  VIO *do_io_write(Continuation * c, int64_t nbytes, IOBufferReader * buf, bool owner = false);
 
46
  void do_io_close(int lerrno = -1);
 
47
  void do_io_shutdown(ShutdownHowTo_t howto);
 
48
 
 
49
  void reenable(VIO * vio);
 
50
 
 
51
public:
 
52
  TransformVConnection * m_tvc;
 
53
  VIO m_read_vio;
 
54
  VIO m_write_vio;
 
55
  volatile int m_event_count;
 
56
  volatile int m_deletable;
 
57
  volatile int m_closed;
 
58
  int m_called_user;
 
59
};
 
60
 
 
61
 
 
62
class TransformVConnection:public VConnection
 
63
{
 
64
public:
 
65
  TransformVConnection(Continuation * cont, APIHook * hooks);
 
66
  ~TransformVConnection();
 
67
 
 
68
  int handle_event(int event, void *edata);
 
69
 
 
70
  VIO *do_io_read(Continuation * c, int64_t nbytes, MIOBuffer * buf);
 
71
  VIO *do_io_write(Continuation * c, int64_t nbytes, IOBufferReader * buf, bool owner = false);
 
72
  void do_io_close(int lerrno = -1);
 
73
  void do_io_shutdown(ShutdownHowTo_t howto);
 
74
 
 
75
  void reenable(VIO * vio);
 
76
 
 
77
public:
 
78
  VConnection * m_transform;
 
79
  Continuation *m_cont;
 
80
  TransformTerminus m_terminus;
 
81
  volatile int m_closed;
 
82
};
 
83
 
 
84
 
 
85
class TransformControl:public Continuation
 
86
{
 
87
public:
 
88
  TransformControl();
 
89
 
 
90
  int handle_event(int event, void *edata);
 
91
 
 
92
public:
 
93
  APIHooks m_hooks;
 
94
  VConnection *m_tvc;
 
95
  IOBufferReader *m_read_buf;
 
96
  MIOBuffer *m_write_buf;
 
97
};
 
98
 
 
99
 
 
100
class NullTransform:public INKVConnInternal
 
101
{
 
102
public:
 
103
  NullTransform(ProxyMutex * mutex);
 
104
  ~NullTransform();
 
105
 
 
106
  int handle_event(int event, void *edata);
 
107
 
 
108
public:
 
109
  MIOBuffer * m_output_buf;
 
110
  IOBufferReader *m_output_reader;
 
111
  VIO *m_output_vio;
 
112
};
 
113
 
 
114
 
 
115
class RangeTransform:public INKVConnInternal
 
116
{
 
117
public:
 
118
  RangeTransform(ProxyMutex * mutex, MIMEField * range_field, HTTPInfo * cache_obj, HTTPHdr * transform_resp);
 
119
  ~RangeTransform();
 
120
 
 
121
  void parse_range_and_compare();
 
122
  int handle_event(int event, void *edata);
 
123
 
 
124
  void transform_to_range();
 
125
  void add_boundary(bool end);
 
126
  void add_sub_header(int index);
 
127
  void change_response_header();
 
128
  void calculate_output_cl();
 
129
  bool is_this_range_not_handled()
 
130
  {
 
131
    return m_not_handle_range;
 
132
  }
 
133
  bool is_range_unsatisfiable()
 
134
  {
 
135
    return m_unsatisfiable_range;
 
136
  }
 
137
 
 
138
  typedef struct _RangeRecord
 
139
  {
 
140
  _RangeRecord() :
 
141
    _start(-1), _end(-1), _done_byte(-1)
 
142
    { }
 
143
 
 
144
    int64_t _start;
 
145
    int64_t _end;
 
146
    int64_t _done_byte;
 
147
  } RangeRecord;
 
148
 
 
149
public:
 
150
  MIOBuffer * m_output_buf;
 
151
  IOBufferReader *m_output_reader;
 
152
  MIMEField *m_range_field;
 
153
  HTTPHdr *m_transform_resp;
 
154
  VIO *m_output_vio;
 
155
  bool m_unsatisfiable_range;
 
156
  bool m_not_handle_range;
 
157
  int64_t m_content_length;
 
158
  int m_num_chars_for_cl;
 
159
  int m_num_range_fields;
 
160
  int m_current_range;
 
161
  const char *m_content_type;
 
162
  int m_content_type_len;
 
163
  RangeRecord *m_ranges;
 
164
  int64_t m_output_cl;
 
165
  int64_t m_done;
 
166
};
 
167
 
 
168
#define PREFETCH
 
169
#ifdef PREFETCH
 
170
class PrefetchProcessor
 
171
{
 
172
public:
 
173
  void start();
 
174
};
 
175
 
 
176
extern PrefetchProcessor prefetchProcessor;
 
177
#endif //PREFETCH
 
178
 
 
179
#endif /* __TRANSFORM_INTERNAL_H__ */