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.
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
![]()
6 years ago
|
#ifndef WEBCC_REQUEST_PARSER_H_
|
||
|
#define WEBCC_REQUEST_PARSER_H_
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
#include <string>
|
||
|
|
||
![]()
6 years ago
|
#include "webcc/parser.h"
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
namespace webcc {
|
||
![]()
8 years ago
|
|
||
![]()
6 years ago
|
class Request;
|
||
![]()
8 years ago
|
|
||
![]()
6 years ago
|
class RequestParser : public Parser {
|
||
![]()
6 years ago
|
public:
|
||
![]()
6 years ago
|
explicit RequestParser(Request* request = nullptr);
|
||
![]()
8 years ago
|
|
||
![]()
6 years ago
|
~RequestParser() override = default;
|
||
![]()
7 years ago
|
|
||
![]()
6 years ago
|
void Init(Request* request);
|
||
![]()
6 years ago
|
|
||
![]()
6 years ago
|
private:
|
||
![]()
6 years ago
|
bool ParseStartLine(const std::string& line) final;
|
||
![]()
8 years ago
|
|
||
![]()
6 years ago
|
// Override to handle multipart form data which is request only.
|
||
![]()
6 years ago
|
bool ParseContent(const char* data, std::size_t length) final;
|
||
![]()
6 years ago
|
|
||
|
// Multipart specific parsing helpers.
|
||
|
|
||
![]()
6 years ago
|
bool ParseMultipartContent(const char* data, std::size_t length);
|
||
![]()
6 years ago
|
bool ParsePartHeaders(bool* need_more_data);
|
||
|
bool GetNextBoundaryLine(std::size_t* b_off, std::size_t* b_count,
|
||
|
bool* ended);
|
||
|
bool IsBoundary(const std::string& line) const;
|
||
|
bool IsBoundaryEnd(const std::string& line) const;
|
||
|
|
||
|
private:
|
||
![]()
6 years ago
|
Request* request_;
|
||
![]()
6 years ago
|
|
||
|
enum Step {
|
||
|
kStart,
|
||
|
kBoundaryParsed,
|
||
|
kHeadersParsed,
|
||
|
kEnded,
|
||
|
};
|
||
|
Step step_ = kStart;
|
||
|
|
||
|
FormPart part_;
|
||
![]()
8 years ago
|
};
|
||
|
|
||
![]()
7 years ago
|
} // namespace webcc
|
||
![]()
8 years ago
|
|
||
![]()
6 years ago
|
#endif // WEBCC_REQUEST_PARSER_H_
|