blob: ca82b08b4e4ff6e8aa271f8b7d52adf971bd797d [file] [log] [blame]
#ifndef QUICHE_HTTP2_ADAPTER_HEADER_VALIDATOR_H_
#define QUICHE_HTTP2_ADAPTER_HEADER_VALIDATOR_H_
#include <string>
#include <vector>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "quiche/http2/adapter/header_validator_base.h"
#include "quiche/common/platform/api/quiche_export.h"
namespace http2 {
namespace adapter {
class QUICHE_EXPORT_PRIVATE HeaderValidator : public HeaderValidatorBase {
public:
HeaderValidator() = default;
void StartHeaderBlock() override;
HeaderStatus ValidateSingleHeader(absl::string_view key,
absl::string_view value) override;
// Returns true if all required pseudoheaders and no extra pseudoheaders are
// present for the given header type.
bool FinishHeaderBlock(HeaderType type) override;
private:
enum ContentLengthStatus {
CONTENT_LENGTH_OK,
CONTENT_LENGTH_SKIP, // Used to handle duplicate content length values.
CONTENT_LENGTH_ERROR,
};
ContentLengthStatus HandleContentLength(absl::string_view value);
bool ValidateAndSetAuthority(absl::string_view authority);
std::vector<std::string> pseudo_headers_;
absl::optional<std::string> authority_ = absl::nullopt;
std::string method_;
std::string path_;
};
} // namespace adapter
} // namespace http2
#endif // QUICHE_HTTP2_ADAPTER_HEADER_VALIDATOR_H_