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.

50 lines
873 B
C++

#ifndef CSOAP_HTTP_PARSER_H_
#define CSOAP_HTTP_PARSER_H_
#include <string>
#include "csoap/common.h"
namespace csoap {
class HttpMessage;
// HttpParser parses HTTP request and response.
class HttpParser {
public:
explicit HttpParser(HttpMessage* message);
bool finished() const {
return finished_;
}
// Reset parsing state.
void Reset();
ErrorCode Parse(const char* data, size_t len);
protected:
// Parse HTTP start line.
virtual ErrorCode ParseStartLine(const std::string& line) = 0;
void ParseContentLength(const std::string& line);
protected:
// The result HTTP message.
HttpMessage* message_;
ErrorCode error_;
// Data waiting to be parsed.
std::string pending_data_;
// Parsing helper flags.
bool start_line_parsed_;
bool header_parsed_;
bool finished_;
};
} // namespace csoap
#endif // CSOAP_HTTP_PARSER_H_