Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
http_response_parser.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_HTTP_PUBLIC_HTTP_RESPONSE_PARSER_H_
20 #define NET_INSTAWEB_HTTP_PUBLIC_HTTP_RESPONSE_PARSER_H_
21 
22 #include <cstdio>
28 
29 namespace net_instaweb {
30 
31 class MessageHandler;
32 class ResponseHeaders;
33 class Writer;
34 
38  public:
39  HttpResponseParser(ResponseHeaders* response_headers, Writer* writer,
40  MessageHandler* handler)
41  : reading_headers_(true),
42  ok_(true),
43  response_headers_(response_headers),
44  writer_(writer),
45  handler_(handler),
46  parser_(response_headers) {
47  }
48 
50  bool ParseFile(FileSystem::InputFile* file);
51 
54  bool Parse(FILE* stream);
55 
58  bool ParseChunk(const StringPiece& data);
59 
60  bool ok() const { return ok_; }
61  bool headers_complete() const { return parser_.headers_complete(); }
62 
63  private:
64  bool reading_headers_;
65  bool ok_;
66  ResponseHeaders* response_headers_;
67  Writer* writer_;
68  MessageHandler* handler_;
69  ResponseHeadersParser parser_;
70 
71 
72 };
73 
74 }
75 
76 #endif
bool ParseChunk(const StringPiece &data)
bool ParseFile(FileSystem::InputFile *file)
Parse complete HTTP response from a file.
Definition: http_response_parser.h:37
Read/write API for HTTP response headers.
Definition: response_headers.h:37
Interface for writing bytes to an output stream.
Definition: writer.h:29
Definition: file_system.h:96
Parses a stream of HTTP header text into a ResponseHeaders instance.
Definition: response_headers_parser.h:30
Definition: message_handler.h:39