couchbase 3.1.1-universal-darwin-20 → 3.2.0-universal-darwin-20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/CMakeLists.txt +3 -1
- data/ext/build_version.hxx.in +1 -1
- data/ext/cmake/Testing.cmake +1 -0
- data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
- data/ext/cmake/VersionInfo.cmake +3 -0
- data/ext/couchbase/bucket.hxx +47 -28
- data/ext/couchbase/cbsasl/client.h +1 -1
- data/ext/couchbase/cbsasl/context.cc +1 -1
- data/ext/couchbase/cbsasl/context.h +3 -3
- data/ext/couchbase/cbsasl/mechanism.cc +5 -8
- data/ext/couchbase/cbsasl/mechanism.h +1 -4
- data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
- data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
- data/ext/couchbase/cluster.hxx +40 -22
- data/ext/couchbase/cluster_options.hxx +7 -1
- data/ext/couchbase/configuration.hxx +37 -16
- data/ext/couchbase/couchbase.cxx +1145 -291
- data/ext/couchbase/error_map.hxx +1 -1
- data/ext/couchbase/errors.hxx +25 -17
- data/ext/couchbase/io/dns_client.hxx +3 -3
- data/ext/couchbase/io/dns_codec.hxx +4 -5
- data/ext/couchbase/io/dns_config.hxx +5 -6
- data/ext/couchbase/io/dns_message.hxx +3 -3
- data/ext/couchbase/io/http_command.hxx +70 -35
- data/ext/couchbase/io/http_session.hxx +4 -3
- data/ext/couchbase/io/http_session_manager.hxx +28 -19
- data/ext/couchbase/io/mcbp_command.hxx +51 -19
- data/ext/couchbase/io/mcbp_context.hxx +1 -1
- data/ext/couchbase/io/mcbp_parser.hxx +4 -4
- data/ext/couchbase/io/mcbp_session.hxx +91 -101
- data/ext/couchbase/io/query_cache.hxx +2 -2
- data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
- data/ext/couchbase/io/retry_reason.hxx +2 -2
- data/ext/couchbase/io/retry_strategy.hxx +1 -6
- data/ext/couchbase/io/streams.hxx +7 -7
- data/ext/couchbase/metrics/logging_meter.hxx +228 -0
- data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
- data/ext/couchbase/metrics/meter.hxx +49 -0
- data/ext/couchbase/metrics/noop_meter.hxx +43 -0
- data/ext/couchbase/operations.hxx +4 -0
- data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
- data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
- data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
- data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
- data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
- data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
- data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
- data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
- data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
- data/ext/couchbase/operations/analytics_link.hxx +39 -0
- data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
- data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
- data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
- data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
- data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
- data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
- data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
- data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
- data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
- data/ext/couchbase/operations/bucket_create.hxx +8 -8
- data/ext/couchbase/operations/bucket_drop.hxx +5 -5
- data/ext/couchbase/operations/bucket_flush.hxx +5 -5
- data/ext/couchbase/operations/bucket_get.hxx +7 -7
- data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
- data/ext/couchbase/operations/bucket_settings.hxx +40 -49
- data/ext/couchbase/operations/bucket_update.hxx +8 -8
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
- data/ext/couchbase/operations/collection_create.hxx +11 -11
- data/ext/couchbase/operations/collection_drop.hxx +12 -10
- data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
- data/ext/couchbase/operations/design_document.hxx +2 -2
- data/ext/couchbase/operations/document_analytics.hxx +29 -36
- data/ext/couchbase/operations/document_append.hxx +3 -3
- data/ext/couchbase/operations/document_decrement.hxx +3 -3
- data/ext/couchbase/operations/document_exists.hxx +2 -2
- data/ext/couchbase/operations/document_get.hxx +3 -3
- data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
- data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
- data/ext/couchbase/operations/document_get_projected.hxx +10 -11
- data/ext/couchbase/operations/document_increment.hxx +3 -3
- data/ext/couchbase/operations/document_insert.hxx +3 -3
- data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
- data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
- data/ext/couchbase/operations/document_prepend.hxx +3 -3
- data/ext/couchbase/operations/document_query.hxx +39 -41
- data/ext/couchbase/operations/document_remove.hxx +3 -3
- data/ext/couchbase/operations/document_replace.hxx +3 -3
- data/ext/couchbase/operations/document_search.hxx +56 -61
- data/ext/couchbase/operations/document_touch.hxx +3 -3
- data/ext/couchbase/operations/document_unlock.hxx +3 -3
- data/ext/couchbase/operations/document_upsert.hxx +3 -3
- data/ext/couchbase/operations/document_view.hxx +23 -23
- data/ext/couchbase/operations/group_drop.hxx +5 -5
- data/ext/couchbase/operations/group_get.hxx +7 -7
- data/ext/couchbase/operations/group_get_all.hxx +6 -6
- data/ext/couchbase/operations/group_upsert.hxx +11 -11
- data/ext/couchbase/operations/http_noop.hxx +6 -6
- data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
- data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
- data/ext/couchbase/operations/query_index_create.hxx +10 -8
- data/ext/couchbase/operations/query_index_drop.hxx +8 -8
- data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
- data/ext/couchbase/operations/rbac.hxx +40 -63
- data/ext/couchbase/operations/role_get_all.hxx +6 -6
- data/ext/couchbase/operations/scope_create.hxx +10 -10
- data/ext/couchbase/operations/scope_drop.hxx +9 -9
- data/ext/couchbase/operations/scope_get_all.hxx +8 -8
- data/ext/couchbase/operations/search_get_stats.hxx +5 -3
- data/ext/couchbase/operations/search_index.hxx +6 -15
- data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
- data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
- data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
- data/ext/couchbase/operations/search_index_drop.hxx +11 -9
- data/ext/couchbase/operations/search_index_get.hxx +11 -9
- data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
- data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
- data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
- data/ext/couchbase/operations/user_drop.hxx +5 -5
- data/ext/couchbase/operations/user_get.hxx +7 -7
- data/ext/couchbase/operations/user_get_all.hxx +6 -6
- data/ext/couchbase/operations/user_upsert.hxx +9 -9
- data/ext/couchbase/operations/view_index_drop.hxx +10 -10
- data/ext/couchbase/operations/view_index_get.hxx +13 -15
- data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
- data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
- data/ext/couchbase/origin.hxx +14 -10
- data/ext/couchbase/platform/backtrace.c +1 -1
- data/ext/couchbase/platform/base64.cc +5 -5
- data/ext/couchbase/platform/base64.h +2 -5
- data/ext/couchbase/protocol/client_opcode.hxx +7 -4
- data/ext/couchbase/protocol/client_request.hxx +2 -2
- data/ext/couchbase/protocol/client_response.hxx +41 -16
- data/ext/couchbase/protocol/cmd_append.hxx +17 -16
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
- data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
- data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
- data/ext/couchbase/protocol/cmd_get.hxx +11 -14
- data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
- data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
- data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
- data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
- data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
- data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
- data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
- data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
- data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
- data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
- data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
- data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
- data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
- data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
- data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
- data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
- data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
- data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
- data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
- data/ext/couchbase/protocol/datatype.hxx +3 -3
- data/ext/couchbase/protocol/durability_level.hxx +2 -2
- data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
- data/ext/couchbase/protocol/hello_feature.hxx +2 -2
- data/ext/couchbase/protocol/magic.hxx +2 -2
- data/ext/couchbase/protocol/server_opcode.hxx +2 -2
- data/ext/couchbase/protocol/server_request.hxx +1 -1
- data/ext/couchbase/protocol/status.hxx +4 -7
- data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
- data/ext/couchbase/service_type.hxx +4 -4
- data/ext/couchbase/tracing/constants.hxx +261 -0
- data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
- data/ext/couchbase/tracing/request_tracer.hxx +77 -0
- data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
- data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
- data/ext/couchbase/utils/byteswap.hxx +1 -1
- data/ext/couchbase/utils/connection_string.hxx +21 -1
- data/ext/couchbase/utils/name_codec.hxx +41 -0
- data/ext/couchbase/utils/url_codec.hxx +236 -0
- data/ext/couchbase/version.hxx +1 -1
- data/ext/test/CMakeLists.txt +1 -0
- data/ext/test/test_native_trivial_query.cxx +60 -0
- data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
- data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
- data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
- data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
- data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
- data/lib/couchbase/cluster.rb +1 -0
- data/lib/couchbase/errors.rb +3 -0
- data/lib/couchbase/libcouchbase.bundle +0 -0
- data/lib/couchbase/management/analytics_index_manager.rb +920 -226
- data/lib/couchbase/management/bucket_manager.rb +207 -69
- data/lib/couchbase/management/collection_manager.rb +173 -61
- data/lib/couchbase/management/query_index_manager.rb +357 -169
- data/lib/couchbase/options.rb +75 -3
- data/lib/couchbase/scope.rb +102 -0
- data/lib/couchbase/utils/time.rb +4 -0
- data/lib/couchbase/version.rb +6 -6
- metadata +48 -5
@@ -0,0 +1,41 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
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
|
+
#pragma once
|
19
|
+
|
20
|
+
#include <sstream>
|
21
|
+
#include <string>
|
22
|
+
|
23
|
+
namespace couchbase::utils
|
24
|
+
{
|
25
|
+
struct analytics {
|
26
|
+
static std::string uncompound_name(const std::string& name)
|
27
|
+
{
|
28
|
+
std::stringstream ss;
|
29
|
+
ss << '`';
|
30
|
+
for (const auto symbol : name) {
|
31
|
+
if (symbol == '/') {
|
32
|
+
ss << "`.`";
|
33
|
+
} else {
|
34
|
+
ss << symbol;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
ss << '`';
|
38
|
+
return ss.str();
|
39
|
+
}
|
40
|
+
};
|
41
|
+
} // namespace couchbase::utils
|
@@ -67,6 +67,17 @@ url_decode(std::string& s)
|
|
67
67
|
return false;
|
68
68
|
}
|
69
69
|
|
70
|
+
std::string
|
71
|
+
url_decode(const std::string& src)
|
72
|
+
{
|
73
|
+
std::string dst{};
|
74
|
+
size_t n = 0;
|
75
|
+
if (url_decode(src.begin(), src.end(), dst.begin(), n)) {
|
76
|
+
dst.resize(n);
|
77
|
+
}
|
78
|
+
return dst;
|
79
|
+
}
|
80
|
+
|
70
81
|
namespace priv
|
71
82
|
{
|
72
83
|
inline bool
|
@@ -176,6 +187,14 @@ url_encode(const Tin& in, Tout& out)
|
|
176
187
|
return url_encode(in.begin(), in.end(), out);
|
177
188
|
}
|
178
189
|
|
190
|
+
std::string
|
191
|
+
url_encode(const std::string& src)
|
192
|
+
{
|
193
|
+
std::string dst{};
|
194
|
+
url_encode(src.begin(), src.end(), dst);
|
195
|
+
return dst;
|
196
|
+
}
|
197
|
+
|
179
198
|
/* See: https://url.spec.whatwg.org/#urlencoded-serializing: */
|
180
199
|
/*
|
181
200
|
* 0x2A
|
@@ -222,4 +241,221 @@ form_encode(const std::string& src)
|
|
222
241
|
return dst;
|
223
242
|
}
|
224
243
|
|
244
|
+
namespace v2
|
245
|
+
{
|
246
|
+
enum class encoding {
|
247
|
+
encode_path,
|
248
|
+
encode_path_segment,
|
249
|
+
encode_host,
|
250
|
+
encode_zone,
|
251
|
+
encode_user_password,
|
252
|
+
encode_query_component,
|
253
|
+
encode_fragment,
|
254
|
+
};
|
255
|
+
|
256
|
+
bool
|
257
|
+
should_escape(char c, encoding mode)
|
258
|
+
{
|
259
|
+
// §2.3 Unreserved characters (alphanum)
|
260
|
+
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9')) {
|
261
|
+
return false;
|
262
|
+
}
|
263
|
+
|
264
|
+
if (mode == encoding::encode_host || mode == encoding::encode_zone) {
|
265
|
+
// §3.2.2 Host allows
|
266
|
+
// sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
|
267
|
+
// as part of reg-name.
|
268
|
+
// We add : because we include :port as part of host.
|
269
|
+
// We add [ ] because we include [ipv6]:port as part of host.
|
270
|
+
// We add < > because they're the only characters left that we could possibly allow, and Parse will reject them if we escape them
|
271
|
+
// (because hosts can't use %-encoding for ASCII bytes).
|
272
|
+
switch (c) {
|
273
|
+
case '!':
|
274
|
+
case '$':
|
275
|
+
case '&':
|
276
|
+
case '\'':
|
277
|
+
case '(':
|
278
|
+
case ')':
|
279
|
+
case '*':
|
280
|
+
case '+':
|
281
|
+
case ',':
|
282
|
+
case ';':
|
283
|
+
case '=':
|
284
|
+
case ':':
|
285
|
+
case '[':
|
286
|
+
case ']':
|
287
|
+
case '<':
|
288
|
+
case '>':
|
289
|
+
case '"':
|
290
|
+
return false;
|
291
|
+
|
292
|
+
default:
|
293
|
+
break;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
switch (c) {
|
298
|
+
case '-':
|
299
|
+
case '_':
|
300
|
+
case '.':
|
301
|
+
case '~':
|
302
|
+
// §2.3 Unreserved characters (mark)
|
303
|
+
return false;
|
304
|
+
|
305
|
+
case '$':
|
306
|
+
case '&':
|
307
|
+
case '+':
|
308
|
+
case ',':
|
309
|
+
case '/':
|
310
|
+
case ':':
|
311
|
+
case ';':
|
312
|
+
case '=':
|
313
|
+
case '?':
|
314
|
+
case '@':
|
315
|
+
// §2.2 Reserved characters (reserved)
|
316
|
+
// Different sections of the URL allow a few of
|
317
|
+
// the reserved characters to appear unescaped.
|
318
|
+
switch (mode) {
|
319
|
+
case encoding::encode_path: // §3.3
|
320
|
+
// The RFC allows : @ & = + $ but saves / ; , for assigning meaning to individual path segments. This package only
|
321
|
+
// manipulates the path as a whole, so we allow those last three as well. That leaves only ? to escape.
|
322
|
+
return c == '?';
|
323
|
+
|
324
|
+
case encoding::encode_path_segment: // §3.3
|
325
|
+
// The RFC allows : @ & = + $ but saves / ; , for assigning meaning to individual path segments.
|
326
|
+
return c == '/' || c == ';' || c == ',' || c == '?';
|
327
|
+
|
328
|
+
case encoding::encode_user_password: // §3.2.1
|
329
|
+
// The RFC allows ';', ':', '&', '=', '+', '$', and ',' in userinfo, so we must escape only '@', '/', and '?'. The
|
330
|
+
// parsing of userinfo treats ':' as special so we must escape that too.
|
331
|
+
return c == '@' || c == '/' || c == '?' || c == ':';
|
332
|
+
|
333
|
+
case encoding::encode_query_component: // §3.4
|
334
|
+
// The RFC reserves (so we must escape) everything.
|
335
|
+
return true;
|
336
|
+
|
337
|
+
case encoding::encode_fragment: // §4.1
|
338
|
+
// The RFC text is silent but the grammar allows everything, so escape nothing.
|
339
|
+
return false;
|
340
|
+
|
341
|
+
default:
|
342
|
+
break;
|
343
|
+
}
|
344
|
+
|
345
|
+
default:
|
346
|
+
break;
|
347
|
+
}
|
348
|
+
|
349
|
+
if (mode == encoding::encode_fragment) {
|
350
|
+
// RFC 3986 §2.2 allows not escaping sub-delims. A subset of sub-delims are included in reserved from RFC 2396 §2.2. The remaining
|
351
|
+
// sub-delims do not need to be escaped. To minimize potential breakage, we apply two restrictions: (1) we always escape sub-delims
|
352
|
+
// outside of the fragment, and (2) we always escape single quote to avoid breaking callers that had previously assumed that single
|
353
|
+
// quotes would be escaped. See issue #19917.
|
354
|
+
switch (c) {
|
355
|
+
case '!':
|
356
|
+
case '(':
|
357
|
+
case ')':
|
358
|
+
case '*':
|
359
|
+
return false;
|
360
|
+
|
361
|
+
default:
|
362
|
+
break;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
// Everything else must be escaped.
|
367
|
+
return true;
|
368
|
+
}
|
369
|
+
|
370
|
+
constexpr auto upper_hex = "0123456789ABCDEF";
|
371
|
+
|
372
|
+
std::string
|
373
|
+
escape(const std::string& s, encoding mode)
|
374
|
+
{
|
375
|
+
std::size_t space_count{ 0 };
|
376
|
+
std::size_t hex_count{ 0 };
|
377
|
+
|
378
|
+
for (const auto& c : s) {
|
379
|
+
if (should_escape(c, mode)) {
|
380
|
+
if (c == ' ' && mode == encoding::encode_query_component) {
|
381
|
+
++space_count;
|
382
|
+
} else {
|
383
|
+
++hex_count;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
if (space_count == 0 && hex_count == 0) {
|
389
|
+
return s;
|
390
|
+
}
|
391
|
+
|
392
|
+
std::size_t required = s.size() + 2 * hex_count;
|
393
|
+
std::string t;
|
394
|
+
t.resize(required);
|
395
|
+
|
396
|
+
if (hex_count == 0) {
|
397
|
+
for (std::size_t i = 0; i < s.size(); ++i) {
|
398
|
+
if (s[i] == ' ') {
|
399
|
+
t[i] = '+';
|
400
|
+
} else {
|
401
|
+
t[i] = s[i];
|
402
|
+
}
|
403
|
+
}
|
404
|
+
return t;
|
405
|
+
}
|
406
|
+
|
407
|
+
std::size_t j{ 0 };
|
408
|
+
for (const auto& c : s) {
|
409
|
+
if (c == ' ' && mode == encoding::encode_query_component) {
|
410
|
+
t[j++] = '+';
|
411
|
+
} else if (should_escape(c, mode)) {
|
412
|
+
t[j++] = '%';
|
413
|
+
t[j++] = upper_hex[(c >> 4U) & 0x0f];
|
414
|
+
t[j++] = upper_hex[c & 0x0f];
|
415
|
+
} else {
|
416
|
+
t[j++] = c;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
return t;
|
420
|
+
}
|
421
|
+
|
422
|
+
/**
|
423
|
+
* Escapes the string so it can be safely placed inside a URL query.
|
424
|
+
*
|
425
|
+
* @param s
|
426
|
+
* @return
|
427
|
+
*/
|
428
|
+
std::string
|
429
|
+
query_escape(const std::string& s)
|
430
|
+
{
|
431
|
+
return escape(s, encoding::encode_query_component);
|
432
|
+
}
|
433
|
+
|
434
|
+
/**
|
435
|
+
* Escapes the string so it can be safely placed inside a URL path segment, replacing special characters (including /) with %XX sequences as
|
436
|
+
* needed.
|
437
|
+
*/
|
438
|
+
std::string
|
439
|
+
path_escape(const std::string& s)
|
440
|
+
{
|
441
|
+
return escape(s, encoding::encode_path);
|
442
|
+
}
|
443
|
+
|
444
|
+
std::string
|
445
|
+
form_encode(const std::map<std::string, std::string>& values)
|
446
|
+
{
|
447
|
+
std::stringstream ss;
|
448
|
+
bool first{ true };
|
449
|
+
for (const auto& [key, value] : values) {
|
450
|
+
if (first) {
|
451
|
+
first = false;
|
452
|
+
} else {
|
453
|
+
ss << '&';
|
454
|
+
}
|
455
|
+
ss << query_escape(key) << '=' << query_escape(value);
|
456
|
+
}
|
457
|
+
return ss.str();
|
458
|
+
}
|
459
|
+
} // namespace v2
|
460
|
+
|
225
461
|
} // namespace couchbase::utils::string_codec
|
data/ext/couchbase/version.hxx
CHANGED
data/ext/test/CMakeLists.txt
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020-2021 Couchbase, Inc.
|
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
|
+
#include "test_helper_native.hxx"
|
19
|
+
|
20
|
+
TEST_CASE("native: trivial non-data query", "[native]")
|
21
|
+
{
|
22
|
+
auto ctx = test_context::load_from_environment();
|
23
|
+
native_init_logger();
|
24
|
+
|
25
|
+
auto connstr = couchbase::utils::parse_connection_string(ctx.connection_string);
|
26
|
+
couchbase::cluster_credentials auth{};
|
27
|
+
auth.username = ctx.username;
|
28
|
+
auth.password = ctx.password;
|
29
|
+
|
30
|
+
asio::io_context io;
|
31
|
+
|
32
|
+
couchbase::cluster cluster(io);
|
33
|
+
auto io_thread = std::thread([&io]() { io.run(); });
|
34
|
+
|
35
|
+
{
|
36
|
+
auto barrier = std::make_shared<std::promise<std::error_code>>();
|
37
|
+
auto f = barrier->get_future();
|
38
|
+
cluster.open(couchbase::origin(auth, connstr), [barrier](std::error_code ec) mutable { barrier->set_value(ec); });
|
39
|
+
auto rc = f.get();
|
40
|
+
INFO(rc.message());
|
41
|
+
REQUIRE_FALSE(rc);
|
42
|
+
}
|
43
|
+
{
|
44
|
+
couchbase::operations::query_request req{ R"(SELECT "ruby rules" AS greeting)" };
|
45
|
+
auto barrier = std::make_shared<std::promise<couchbase::operations::query_response>>();
|
46
|
+
auto f = barrier->get_future();
|
47
|
+
cluster.execute_http(req, [barrier](couchbase::operations::query_response resp) mutable { barrier->set_value(resp); });
|
48
|
+
auto resp = f.get();
|
49
|
+
INFO(resp.ctx.ec.message());
|
50
|
+
REQUIRE_FALSE(resp.ctx.ec);
|
51
|
+
}
|
52
|
+
{
|
53
|
+
auto barrier = std::make_shared<std::promise<void>>();
|
54
|
+
auto f = barrier->get_future();
|
55
|
+
cluster.close([barrier]() { barrier->set_value(); });
|
56
|
+
f.get();
|
57
|
+
}
|
58
|
+
|
59
|
+
io_thread.join();
|
60
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
cmake_minimum_required(VERSION 3.5)
|
2
|
+
|
3
|
+
project(hdr_histogram VERSION 0.10.0 LANGUAGES C)
|
4
|
+
|
5
|
+
include(GNUInstallDirs)
|
6
|
+
include(CMakePackageConfigHelpers)
|
7
|
+
|
8
|
+
# Follow all steps below in order to calculate new ABI version when updating the library
|
9
|
+
# NOTE: THIS IS UNRELATED to the actual project version
|
10
|
+
#
|
11
|
+
# 1. If the library source code has changed at all since the last update, then increment revision
|
12
|
+
# 2. If any interfaces have been added, removed, or changed since the last update, increment current and set revision to 0.
|
13
|
+
# 3. If any interfaces have been added since the last public release, then increment age.
|
14
|
+
# 4. If any interfaces have been removed since the last public release, then set age to 0.
|
15
|
+
|
16
|
+
set(HDR_SOVERSION_CURRENT 6)
|
17
|
+
set(HDR_SOVERSION_AGE 1)
|
18
|
+
set(HDR_SOVERSION_REVISION 1)
|
19
|
+
|
20
|
+
set(HDR_VERSION ${HDR_SOVERSION_CURRENT}.${HDR_SOVERSION_AGE}.${HDR_SOVERSION_REVISION})
|
21
|
+
set(HDR_SOVERSION ${HDR_SOVERSION_CURRENT})
|
22
|
+
option(HDR_LOG_REQUIRED "HDR Logging component required" ON)
|
23
|
+
|
24
|
+
set(CMAKE_C_STANDARD 99)
|
25
|
+
set(CMAKE_C_STANDARD_REQUIRED ON)
|
26
|
+
set(CMAKE_C_EXTENSIONS OFF)
|
27
|
+
|
28
|
+
set(CMAKE_CXX_STANDARD 11)
|
29
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
30
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
31
|
+
|
32
|
+
if(UNIX)
|
33
|
+
add_compile_options(
|
34
|
+
-Wall
|
35
|
+
-Wno-unknown-pragmas
|
36
|
+
-Wextra
|
37
|
+
-Wshadow
|
38
|
+
-Winit-self
|
39
|
+
-Wpedantic
|
40
|
+
$<$<COMPILE_LANGUAGE:C>:-Wmissing-prototypes>)
|
41
|
+
add_definitions(-D_GNU_SOURCE)
|
42
|
+
endif()
|
43
|
+
|
44
|
+
find_package(ZLIB)
|
45
|
+
find_package(Threads REQUIRED)
|
46
|
+
|
47
|
+
set(HDR_LOG_ENABLED ${ZLIB_FOUND})
|
48
|
+
if (${HDR_LOG_REQUIRED} AND NOT HDR_LOG_ENABLED)
|
49
|
+
message(SEND_ERROR "HDR_LOG_REQUIRED=ON and unable to find zlib library")
|
50
|
+
endif()
|
51
|
+
|
52
|
+
add_subdirectory(src)
|
53
|
+
|
54
|
+
option(HDR_HISTOGRAM_BUILD_PROGRAMS "Build tests and examples" ON)
|
55
|
+
if(HDR_HISTOGRAM_BUILD_PROGRAMS)
|
56
|
+
include(CTest)
|
57
|
+
|
58
|
+
if(BUILD_TESTING)
|
59
|
+
add_subdirectory(test)
|
60
|
+
endif()
|
61
|
+
|
62
|
+
add_subdirectory(examples)
|
63
|
+
endif()
|
64
|
+
|
65
|
+
write_basic_package_version_file(
|
66
|
+
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
|
67
|
+
VERSION ${PROJECT_VERSION}
|
68
|
+
COMPATIBILITY AnyNewerVersion)
|
69
|
+
configure_file(
|
70
|
+
config.cmake.in
|
71
|
+
${PROJECT_NAME}-config.cmake
|
72
|
+
@ONLY)
|
73
|
+
install(
|
74
|
+
EXPORT ${PROJECT_NAME}-targets
|
75
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
76
|
+
NAMESPACE ${PROJECT_NAME}::)
|
77
|
+
install(
|
78
|
+
FILES
|
79
|
+
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
|
80
|
+
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
|
81
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
|
82
|
+
|
83
|
+
set(CPACK_GENERATOR "TGZ")
|
84
|
+
include(CPack)
|