grpc
src
core
lib
slice
percent_encoding.h
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2016 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
#ifndef GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H
20
#define GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H
21
22
/* Percent encoding and decoding of slices.
23
Transforms arbitrary strings into safe-for-transmission strings by using
24
variants of percent encoding (RFC 3986).
25
Two major variants are supplied: one that strictly matches URL encoding,
26
and another which applies percent encoding only to non-http2 header
27
bytes (the 'compatible' variant) */
28
29
#include <
grpc/support/port_platform.h
>
30
31
#include "
src/core/lib/slice/slice.h
"
32
33
namespace
grpc_core
{
34
35
enum class
PercentEncodingType
{
36
// Flags [A-Za-z0-9-_.~] as unreserved bytes for the percent encoding routines
37
URL
,
38
// Flags ascii7 non-control characters excluding '%' as unreserved bytes for
39
// the percent encoding routines
40
Compatible
41
};
42
43
// Percent-encode a slice, returning the new slice (this cannot fail):
44
// unreserved_bytes is a bitfield indicating which bytes are considered
45
// unreserved and thus do not need percent encoding
46
Slice
PercentEncodeSlice
(Slice
slice
,
PercentEncodingType
type
);
47
// Percent-decode a slice, permissively.
48
// If a % triplet can not be decoded, pass it through verbatim.
49
// This cannot fail.
50
Slice
PermissivePercentDecodeSlice
(Slice slice_in);
51
52
}
// namespace grpc_core
53
54
#endif
/* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */
grpc_core::PermissivePercentDecodeSlice
Slice PermissivePercentDecodeSlice(Slice slice_in)
Definition:
percent_encoding.cc:130
slice.h
grpc_core::PercentEncodingType::URL
@ URL
grpc_core
Definition:
call_metric_recorder.h:31
grpc_core::PercentEncodingType::Compatible
@ Compatible
slice
grpc_slice slice
Definition:
src/core/lib/surface/server.cc:467
grpc_core::PercentEncodingType
PercentEncodingType
Definition:
percent_encoding.h:35
asyncio_get_stats.type
type
Definition:
asyncio_get_stats.py:37
grpc_core::PercentEncodeSlice
Slice PercentEncodeSlice(Slice slice, PercentEncodingType type)
Definition:
percent_encoding.cc:84
port_platform.h
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:42