1
// Copyright 2012 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_COMMON_HTTP_STRING_BUILDER_H_
16
#define MOD_SPDY_COMMON_HTTP_STRING_BUILDER_H_
20
#include "base/basictypes.h"
21
#include "mod_spdy/common/http_request_visitor_interface.h"
25
// An HttpRequestVisitorInterface class that appends to a std::string.
26
class HttpStringBuilder : public HttpRequestVisitorInterface {
28
explicit HttpStringBuilder(std::string* str);
29
virtual ~HttpStringBuilder();
31
bool is_complete() const { return state_ == COMPLETE; }
33
// HttpRequestVisitorInterface methods:
34
virtual void OnRequestLine(const base::StringPiece& method,
35
const base::StringPiece& path,
36
const base::StringPiece& version);
37
virtual void OnLeadingHeader(const base::StringPiece& key,
38
const base::StringPiece& value);
39
virtual void OnLeadingHeadersComplete();
40
virtual void OnRawData(const base::StringPiece& data);
41
virtual void OnDataChunk(const base::StringPiece& data);
42
virtual void OnDataChunksComplete();
43
virtual void OnTrailingHeader(const base::StringPiece& key,
44
const base::StringPiece& value);
45
virtual void OnTrailingHeadersComplete();
46
virtual void OnComplete();
52
LEADING_HEADERS_COMPLETE,
57
TRAILING_HEADERS_COMPLETE,
61
std::string* const string_;
64
DISALLOW_COPY_AND_ASSIGN(HttpStringBuilder);
67
} // namespace mod_spdy
69
#endif // MOD_SPDY_COMMON_HTTP_STRING_BUILDER_H_