1
// Copyright 2010 Google Inc.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
15
#ifndef MOD_SPDY_APACHE_FILTERS_HTTP_TO_SPDY_FILTER_H_
16
#define MOD_SPDY_APACHE_FILTERS_HTTP_TO_SPDY_FILTER_H_
20
#include "apr_buckets.h"
21
#include "util_filter.h"
23
#include "base/basictypes.h"
24
#include "mod_spdy/common/http_to_spdy_converter.h"
30
// An Apache filter for converting HTTP data into SPDY frames and sending them
31
// to the output queue of a SpdyStream object. This is intended to be the
32
// outermost filter in the output chain of one of our slave connections,
33
// essentially taking the place of the network socket.
35
// In a previous implementation of this filter, we made this a TRANSCODE-level
36
// filter rather than a NETWORK-level filter; this had the advantage that we
37
// could pull HTTP header data directly from the Apache request object, rather
38
// than having to parse the headers. However, it had the disadvantage of being
39
// fragile -- for example, we had an additional output filter whose sole job
40
// was to deceive Apache into not chunking the response body, and several
41
// different hooks to try to make sure our output filters stayed in place even
42
// in the face of Apache's weird error-handling paths. Also, using a
43
// NETWORK-level filter decreases the likelihood that we'll break other modules
44
// that try to use connection-level filters.
45
class HttpToSpdyFilter {
47
explicit HttpToSpdyFilter(SpdyStream* stream);
50
// Read data from the given brigade and write the result through the given
51
// filter. This method is responsible for driving the HTTP to SPDY conversion
53
apr_status_t Write(ap_filter_t* filter, apr_bucket_brigade* input_brigade);
56
class ReceiverImpl : public HttpToSpdyConverter::SpdyReceiver {
58
explicit ReceiverImpl(SpdyStream* stream);
59
virtual ~ReceiverImpl();
60
virtual void ReceiveSynReply(net::SpdyHeaderBlock* headers, bool flag_fin);
61
virtual void ReceiveData(base::StringPiece data, bool flag_fin);
64
friend class HttpToSpdyFilter;
65
SpdyStream* const stream_;
67
DISALLOW_COPY_AND_ASSIGN(ReceiverImpl);
70
ReceiverImpl receiver_;
71
HttpToSpdyConverter converter_;
72
bool eos_bucket_received_;
74
DISALLOW_COPY_AND_ASSIGN(HttpToSpdyFilter);
77
} // namespace mod_spdy
79
#endif // MOD_SPDY_APACHE_FILTERS_HTTP_TO_SPDY_FILTER_H_