You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
817 B
C
46 lines
817 B
C
![]()
7 years ago
|
#ifndef WEBCC_HTTP_PARSER_H_
|
||
|
#define WEBCC_HTTP_PARSER_H_
|
||
![]()
8 years ago
|
|
||
|
#include <string>
|
||
![]()
7 years ago
|
#include "webcc/common.h"
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
namespace webcc {
|
||
![]()
8 years ago
|
|
||
|
class HttpMessage;
|
||
|
|
||
|
// HttpParser parses HTTP request and response.
|
||
|
class HttpParser {
|
||
|
public:
|
||
|
explicit HttpParser(HttpMessage* message);
|
||
|
|
||
|
bool finished() const {
|
||
|
return finished_;
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
Error Parse(const char* data, size_t len);
|
||
![]()
8 years ago
|
|
||
|
protected:
|
||
|
// Parse HTTP start line.
|
||
![]()
8 years ago
|
virtual Error ParseStartLine(const std::string& line) = 0;
|
||
![]()
8 years ago
|
|
||
|
void ParseContentLength(const std::string& line);
|
||
|
|
||
|
protected:
|
||
|
// The result HTTP message.
|
||
|
HttpMessage* message_;
|
||
|
|
||
![]()
8 years ago
|
Error error_;
|
||
![]()
8 years ago
|
|
||
|
// Data waiting to be parsed.
|
||
|
std::string pending_data_;
|
||
|
|
||
|
// Parsing helper flags.
|
||
|
bool start_line_parsed_;
|
||
|
bool header_parsed_;
|
||
|
bool finished_;
|
||
|
};
|
||
|
|
||
![]()
7 years ago
|
} // namespace webcc
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
#endif // WEBCC_HTTP_PARSER_H_
|