MCPcopy Create free account
hub / github.com/apache/trafficserver / appendEncoded

Function appendEncoded

plugins/cachekey/cachekey.cc:37–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37static void
38appendEncoded(String &target, const char *s, size_t len)
39{
40 if (0 == len) {
41 return;
42 }
43
44 char tmp[len * 3 + 1];
45 size_t written;
46
47 /* The default table does not encode the comma, so we need to use our own table here. */
48 static const unsigned char map[32] = {
49 0xFF, 0xFF, 0xFF,
50 0xFF, // control
51 0xB4, // space " # %
52 0x08, // ,
53 0x00, //
54 0x0A, // < >
55 0x00, 0x00, //
56 0x00, //
57 0x1E, 0x80, // [ \ ] ^ `
58 0x00, 0x00, //
59 0x1F, // { | } ~ DEL
60 0x00, 0x00, 0x00,
61 0x00, // all non-ascii characters unmodified
62 0x00, 0x00, 0x00,
63 0x00, // .
64 0x00, 0x00, 0x00,
65 0x00, // .
66 0x00, 0x00, 0x00,
67 0x00 // .
68 };
69
70 if (TSStringPercentEncode(s, len, tmp, sizeof(tmp), &written, map) == TS_SUCCESS) {
71 target.append(tmp, written);
72 } else {
73 /* If the encoding fails (pretty unlikely), then just append what we have.
74 * This is just a best-effort encoding anyway. */
75 target.append(s, len);
76 }
77}
78
79template <typename ContainerType, typename Iterator>
80static String

Callers 1

appendMethod · 0.85

Calls 2

TSStringPercentEncodeFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected