|
|
@ -29,14 +29,6 @@ |
|
|
|
#include "src/core/lib/gprpp/memory.h" |
|
|
|
#include "src/core/lib/gprpp/memory.h" |
|
|
|
#include "src/core/lib/iomgr/error.h" |
|
|
|
#include "src/core/lib/iomgr/error.h" |
|
|
|
|
|
|
|
|
|
|
|
#if __cplusplus > 201103l |
|
|
|
|
|
|
|
#define GRPC_VALIDATE_METADATA_CONSTEXPR_FN constexpr |
|
|
|
|
|
|
|
#define GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE constexpr |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
#define GRPC_VALIDATE_METADATA_CONSTEXPR_FN |
|
|
|
|
|
|
|
#define GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE const |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static grpc_error_handle conforms_to(const grpc_slice& slice, |
|
|
|
static grpc_error_handle conforms_to(const grpc_slice& slice, |
|
|
|
const grpc_core::BitSet<256>& legal_bits, |
|
|
|
const grpc_core::BitSet<256>& legal_bits, |
|
|
|
const char* err_desc) { |
|
|
|
const char* err_desc) { |
|
|
@ -68,7 +60,7 @@ static int error2int(grpc_error_handle error) { |
|
|
|
namespace { |
|
|
|
namespace { |
|
|
|
class LegalHeaderKeyBits : public grpc_core::BitSet<256> { |
|
|
|
class LegalHeaderKeyBits : public grpc_core::BitSet<256> { |
|
|
|
public: |
|
|
|
public: |
|
|
|
GRPC_VALIDATE_METADATA_CONSTEXPR_FN LegalHeaderKeyBits() { |
|
|
|
constexpr LegalHeaderKeyBits() { |
|
|
|
for (int i = 'a'; i <= 'z'; i++) set(i); |
|
|
|
for (int i = 'a'; i <= 'z'; i++) set(i); |
|
|
|
for (int i = '0'; i <= '9'; i++) set(i); |
|
|
|
for (int i = '0'; i <= '9'; i++) set(i); |
|
|
|
set('-'); |
|
|
|
set('-'); |
|
|
@ -76,8 +68,7 @@ class LegalHeaderKeyBits : public grpc_core::BitSet<256> { |
|
|
|
set('.'); |
|
|
|
set('.'); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE LegalHeaderKeyBits |
|
|
|
constexpr LegalHeaderKeyBits g_legal_header_key_bits; |
|
|
|
g_legal_header_key_bits; |
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
grpc_error_handle grpc_validate_header_key_is_legal(const grpc_slice& slice) { |
|
|
|
grpc_error_handle grpc_validate_header_key_is_legal(const grpc_slice& slice) { |
|
|
@ -103,14 +94,13 @@ int grpc_header_key_is_legal(grpc_slice slice) { |
|
|
|
namespace { |
|
|
|
namespace { |
|
|
|
class LegalHeaderNonBinValueBits : public grpc_core::BitSet<256> { |
|
|
|
class LegalHeaderNonBinValueBits : public grpc_core::BitSet<256> { |
|
|
|
public: |
|
|
|
public: |
|
|
|
GRPC_VALIDATE_METADATA_CONSTEXPR_FN LegalHeaderNonBinValueBits() { |
|
|
|
constexpr LegalHeaderNonBinValueBits() { |
|
|
|
for (int i = 32; i <= 126; i++) { |
|
|
|
for (int i = 32; i <= 126; i++) { |
|
|
|
set(i); |
|
|
|
set(i); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE LegalHeaderNonBinValueBits |
|
|
|
constexpr LegalHeaderNonBinValueBits g_legal_header_non_bin_value_bits; |
|
|
|
g_legal_header_non_bin_value_bits; |
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
grpc_error_handle grpc_validate_header_nonbin_value_is_legal( |
|
|
|
grpc_error_handle grpc_validate_header_nonbin_value_is_legal( |
|
|
|