libcouchbase 0.0.7 → 0.0.8
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/ext/libcouchbase/.gitignore +2 -0
- data/ext/libcouchbase/CMakeLists.txt +5 -7
- data/ext/libcouchbase/README.markdown +2 -2
- data/ext/libcouchbase/RELEASE_NOTES.markdown +49 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +2 -1
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +2 -0
- data/ext/libcouchbase/cmake/defs.mk.in +0 -2
- data/ext/libcouchbase/cmake/source_files.cmake +34 -14
- data/ext/libcouchbase/configure.pl +1 -1
- data/ext/libcouchbase/contrib/genhash/genhash.h +6 -0
- data/ext/libcouchbase/include/libcouchbase/auth.h +10 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +10 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +7 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +13 -1
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +1 -1
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +9 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
- data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +21 -1132
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
- data/ext/libcouchbase/src/README.md +0 -2
- data/ext/libcouchbase/src/auth-priv.h +1 -0
- data/ext/libcouchbase/src/auth.cc +10 -0
- data/ext/libcouchbase/src/bootstrap.cc +216 -0
- data/ext/libcouchbase/src/bootstrap.h +50 -39
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +455 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +528 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.cc +115 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +407 -386
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +378 -0
- data/ext/libcouchbase/src/cbft.cc +22 -27
- data/ext/libcouchbase/src/cntl.cc +24 -24
- data/ext/libcouchbase/src/connspec.cc +30 -1
- data/ext/libcouchbase/src/connspec.h +17 -0
- data/ext/libcouchbase/src/dns-srv.cc +143 -0
- data/ext/libcouchbase/src/{dump.c → dump.cc} +8 -11
- data/ext/libcouchbase/src/getconfig.cc +73 -0
- data/ext/libcouchbase/src/handler.cc +84 -85
- data/ext/libcouchbase/src/hostlist.cc +0 -1
- data/ext/libcouchbase/src/hostlist.h +6 -1
- data/ext/libcouchbase/src/http/http-priv.h +125 -112
- data/ext/libcouchbase/src/http/http.cc +9 -29
- data/ext/libcouchbase/src/http/http.h +1 -34
- data/ext/libcouchbase/src/http/http_io.cc +22 -26
- data/ext/libcouchbase/src/instance.cc +102 -28
- data/ext/libcouchbase/src/internal.h +47 -29
- data/ext/libcouchbase/src/jsparse/parser.cc +146 -202
- data/ext/libcouchbase/src/jsparse/parser.h +91 -98
- data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
- data/ext/libcouchbase/src/lcbio/connect.cc +562 -0
- data/ext/libcouchbase/src/lcbio/connect.h +9 -2
- data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
- data/ext/libcouchbase/src/lcbio/iotable.h +61 -16
- data/ext/libcouchbase/src/lcbio/ioutils.h +1 -1
- data/ext/libcouchbase/src/lcbio/manager.c +2 -2
- data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
- data/ext/libcouchbase/src/mc/mcreq.h +9 -2
- data/ext/libcouchbase/src/mcserver/mcserver.cc +723 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +160 -70
- data/ext/libcouchbase/src/mcserver/negotiate.cc +118 -152
- data/ext/libcouchbase/src/mcserver/negotiate.h +85 -74
- data/ext/libcouchbase/src/mctx-helper.h +51 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
- data/ext/libcouchbase/src/n1ql/n1ql.cc +56 -32
- data/ext/libcouchbase/src/{newconfig.c → newconfig.cc} +42 -70
- data/ext/libcouchbase/src/nodeinfo.cc +4 -8
- data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
- data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
- data/ext/libcouchbase/src/operations/{durability-cas.c → durability-cas.cc} +92 -76
- data/ext/libcouchbase/src/operations/{durability-seqno.c → durability-seqno.cc} +55 -49
- data/ext/libcouchbase/src/operations/durability.cc +643 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +212 -124
- data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
- data/ext/libcouchbase/src/operations/{observe-seqno.c → observe-seqno.cc} +5 -8
- data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +69 -94
- data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
- data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
- data/ext/libcouchbase/src/operations/{stats.c → stats.cc} +66 -78
- data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
- data/ext/libcouchbase/src/operations/subdoc.cc +38 -18
- data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
- data/ext/libcouchbase/src/packetutils.h +200 -137
- data/ext/libcouchbase/src/probes.d +1 -1
- data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +3 -4
- data/ext/libcouchbase/src/retryq.cc +394 -0
- data/ext/libcouchbase/src/retryq.h +116 -104
- data/ext/libcouchbase/src/settings.h +2 -1
- data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
- data/ext/libcouchbase/src/trace.h +8 -8
- data/ext/libcouchbase/src/vbucket/vbucket.c +0 -1
- data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
- data/ext/libcouchbase/src/views/docreq.h +24 -30
- data/ext/libcouchbase/src/views/viewreq.cc +318 -0
- data/ext/libcouchbase/src/views/viewreq.h +43 -13
- data/ext/libcouchbase/src/{wait.c → wait.cc} +12 -17
- data/ext/libcouchbase/tests/basic/t_connstr.cc +89 -50
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -78
- data/ext/libcouchbase/tests/basic/t_packet.cc +35 -42
- data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +94 -111
- data/ext/libcouchbase/tests/iotests/t_sched.cc +1 -2
- data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +1 -1
- data/lib/libcouchbase/version.rb +1 -1
- metadata +36 -39
- data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
- data/ext/libcouchbase/src/bootstrap.c +0 -269
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +0 -495
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
- data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
- data/ext/libcouchbase/src/getconfig.c +0 -100
- data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
- data/ext/libcouchbase/src/lcbio/connect.c +0 -557
- data/ext/libcouchbase/src/mcserver/mcserver.c +0 -784
- data/ext/libcouchbase/src/operations/durability.c +0 -668
- data/ext/libcouchbase/src/packetutils.c +0 -60
- data/ext/libcouchbase/src/retryq.c +0 -424
- data/ext/libcouchbase/src/simplestring.c +0 -211
- data/ext/libcouchbase/src/simplestring.h +0 -228
- data/ext/libcouchbase/src/ssobuf.h +0 -82
- data/ext/libcouchbase/src/views/viewreq.c +0 -358
- data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
|
@@ -65,10 +65,15 @@ struct Hostlist {
|
|
|
65
65
|
|
|
66
66
|
std::vector<lcb_host_t> hosts;
|
|
67
67
|
std::vector<const char *> hoststrs;
|
|
68
|
+
static Hostlist* from_c(hostlist_st* src) {
|
|
69
|
+
return reinterpret_cast<Hostlist*>(src);
|
|
70
|
+
}
|
|
68
71
|
};
|
|
69
72
|
}
|
|
70
73
|
typedef lcb::Hostlist* hostlist_t;
|
|
71
|
-
|
|
74
|
+
|
|
75
|
+
struct hostlist_st : lcb::Hostlist {
|
|
76
|
+
};
|
|
72
77
|
#endif
|
|
73
78
|
|
|
74
79
|
#ifdef __cplusplus
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
#include <libcouchbase/couchbase.h>
|
|
22
22
|
#include <lcbio/lcbio.h>
|
|
23
23
|
#include <lcbio/timer-ng.h>
|
|
24
|
+
#include <lcbio/timer-cxx.h>
|
|
24
25
|
#include <lcbht/lcbht.h>
|
|
25
26
|
#include "contrib/http_parser/http_parser.h"
|
|
26
27
|
#include "http.h"
|
|
@@ -41,100 +42,34 @@ struct Header {
|
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
struct Request {
|
|
44
|
-
enum State {
|
|
45
|
-
/**
|
|
46
|
-
* The request is still ongoing. Callbacks are still active.
|
|
47
|
-
* Note that this essentially means the absence of any flags :)
|
|
48
|
-
*/
|
|
49
|
-
ONGOING = 0,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* This flag is set when the on_complete callback has been invoked. This
|
|
53
|
-
* is used as a marker to prevent us from calling that callback more than
|
|
54
|
-
* once per request
|
|
55
|
-
*/
|
|
56
|
-
CBINVOKED = 1 << 0,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* This flag is set by lcb_http_request_finish, and indicates that the
|
|
60
|
-
* request is no longer active per se. This means that while the request
|
|
61
|
-
* may still be valid in memory, it is simply waiting for any pending I/O
|
|
62
|
-
* operations to close, so the reference count can hit zero.
|
|
63
|
-
*/
|
|
64
|
-
FINISHED = 1 << 1,
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Internal flag used to indicate that finish() should not not attempt
|
|
68
|
-
* to modify any instance-level globals. This is currently used
|
|
69
|
-
* from within lcb_destroy()
|
|
70
|
-
*/
|
|
71
|
-
NOLCB = 1 << 2
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
lcb_t instance; /**< Library handle */
|
|
75
|
-
std::string url; /**<Base URL: http://host:port/path?query*/
|
|
76
|
-
std::string host; /**< Host, derived from URL */
|
|
77
|
-
std::string port; /**< Port, derived from URL */
|
|
78
|
-
|
|
79
|
-
std::string pending_redirect; /**< New redirected URL */
|
|
80
|
-
bool has_pending_redirect() const { return !pending_redirect.empty(); }
|
|
81
|
-
const std::vector<char> body; /**< Input body (for POST/PUT) */
|
|
82
|
-
|
|
83
|
-
/** Request buffer (excluding body). Reassembled from inputs */
|
|
84
|
-
std::vector<char> preamble;
|
|
85
|
-
|
|
86
|
-
struct http_parser_url url_info; /**< Parser info for the URL */
|
|
87
|
-
const lcb_http_method_t method; /**< Request method constant */
|
|
88
|
-
const bool chunked; /**< Whether to invoke callback for each data chunk */
|
|
89
|
-
bool paused; /**< See pause() and resume() */
|
|
90
|
-
const void * const command_cookie; /** User context for callback */
|
|
91
|
-
size_t refcount; /** Initialized to 1. See incref() and decref() */
|
|
92
|
-
int redircount; /** Times this request was redirected */
|
|
93
|
-
|
|
94
45
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
46
|
+
* Initializes the request. This simply copies the relevant fields from the
|
|
47
|
+
* body and initializes instance members to their default values. The static
|
|
48
|
+
* ::create() method should be used instead to construct a new object
|
|
98
49
|
*/
|
|
99
|
-
|
|
50
|
+
inline Request(lcb_t instance, const void *cookie, const lcb_CMDHTTP* cmd);
|
|
100
51
|
|
|
101
|
-
/**
|
|
102
|
-
|
|
52
|
+
/** Creates a new request object and verifies the input (setup_inputs()) */
|
|
53
|
+
static Request * create(lcb_t instance, const void *cookie,
|
|
54
|
+
const lcb_CMDHTTP *cmd, lcb_error_t *rc);
|
|
103
55
|
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
* match this number, the ::used_nodes field is cleared
|
|
107
|
-
*/
|
|
108
|
-
int last_vbcrev;
|
|
56
|
+
/** Pause IO on this request */
|
|
57
|
+
void pause();
|
|
109
58
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
59
|
+
/** Resume previously paused IO */
|
|
60
|
+
void resume();
|
|
61
|
+
|
|
62
|
+
/** Cancel and finish this request, suppressing callbacks */
|
|
63
|
+
void cancel();
|
|
113
64
|
|
|
114
65
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
66
|
+
* Start all operations required to make this request. This should be
|
|
67
|
+
* called once all inputs have been completed. If successful, I/O operations
|
|
68
|
+
* will begin (this function calls start_io())
|
|
117
69
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
/** Backing buffers for response headers */
|
|
121
|
-
std::vector<Header> response_headers;
|
|
122
|
-
|
|
123
|
-
/** Callback to invoke */
|
|
124
|
-
lcb_RESPCALLBACK callback;
|
|
125
|
-
|
|
126
|
-
// IO variables
|
|
127
|
-
lcbio_pTABLE io;
|
|
128
|
-
lcbio_pCTX ioctx;
|
|
129
|
-
lcbio_pTIMER timer;
|
|
130
|
-
lcbio_CONNREQ creq;
|
|
131
|
-
|
|
132
|
-
/** HTTP Protocol parser */
|
|
133
|
-
lcbht_pPARSER parser;
|
|
134
|
-
|
|
135
|
-
/** overrides default timeout if nonzero */
|
|
136
|
-
const uint32_t user_timeout;
|
|
70
|
+
lcb_error_t submit();
|
|
137
71
|
|
|
72
|
+
bool has_pending_redirect() const { return !pending_redirect.empty(); }
|
|
138
73
|
/**
|
|
139
74
|
* @return The effective timeout. This is either the user timeout or the
|
|
140
75
|
* default timeout for the API type
|
|
@@ -152,13 +87,6 @@ struct Request {
|
|
|
152
87
|
*/
|
|
153
88
|
bool is_ongoing() const { return status == ONGOING; }
|
|
154
89
|
|
|
155
|
-
/**
|
|
156
|
-
* Initializes the request. This simply copies the relevant fields from the
|
|
157
|
-
* body and initializes instance members to their default values. The static
|
|
158
|
-
* ::create() method should be used instead to construct a new object
|
|
159
|
-
*/
|
|
160
|
-
inline Request(lcb_t instance, const void *cookie, const lcb_CMDHTTP* cmd);
|
|
161
|
-
|
|
162
90
|
/**
|
|
163
91
|
* Sets up inputs from the command. This should really be in the
|
|
164
92
|
* constructor, however we also need a return value. The ::create()
|
|
@@ -180,10 +108,6 @@ struct Request {
|
|
|
180
108
|
const char *get_api_node(lcb_error_t &rc);
|
|
181
109
|
const char *get_api_node() { lcb_error_t dummy; return get_api_node(dummy); }
|
|
182
110
|
|
|
183
|
-
/** Creates a new request object and verifies the input (setup_inputs()) */
|
|
184
|
-
static Request * create(lcb_t instance, const void *cookie,
|
|
185
|
-
const lcb_CMDHTTP *cmd, lcb_error_t *rc);
|
|
186
|
-
|
|
187
111
|
/**
|
|
188
112
|
* Sets the URL for the field
|
|
189
113
|
* @param base The URL base (i.e. http://foo.com)
|
|
@@ -220,13 +144,6 @@ struct Request {
|
|
|
220
144
|
inline void add_to_preamble(const std::string&);
|
|
221
145
|
inline void add_to_preamble(const Header&);
|
|
222
146
|
|
|
223
|
-
/**
|
|
224
|
-
* Start all operations required to make this request. This should be
|
|
225
|
-
* called once all inputs have been completed. If successful, I/O operations
|
|
226
|
-
* will begin (this function calls start_io())
|
|
227
|
-
*/
|
|
228
|
-
lcb_error_t submit();
|
|
229
|
-
|
|
230
147
|
/**
|
|
231
148
|
* Starts the IO on the current request. This really belongs in submit(),
|
|
232
149
|
* but submit() handles building the request while start_io() sets up
|
|
@@ -241,7 +158,7 @@ struct Request {
|
|
|
241
158
|
|
|
242
159
|
// Helper functions for parsing response data from network
|
|
243
160
|
inline int handle_parse_chunked(const char *buf, unsigned nbuf);
|
|
244
|
-
inline void assign_response_headers(const
|
|
161
|
+
inline void assign_response_headers(const lcb::htparse::Response&);
|
|
245
162
|
|
|
246
163
|
/**
|
|
247
164
|
* Called when a redirect has happened. pending_redirect must not be empty.
|
|
@@ -273,14 +190,15 @@ struct Request {
|
|
|
273
190
|
**/
|
|
274
191
|
void finish_or_retry(lcb_error_t rc);
|
|
275
192
|
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Change the callback for this request. This is used to indicate that
|
|
195
|
+
* a custom internal callback is used, rather than the one installed via
|
|
196
|
+
* lcb_install_callback3
|
|
197
|
+
* @param callback_ The internal callback to invoke
|
|
198
|
+
*/
|
|
199
|
+
void set_callback(lcb_RESPCALLBACK callback_) {
|
|
200
|
+
callback = callback_;
|
|
201
|
+
}
|
|
284
202
|
|
|
285
203
|
/**
|
|
286
204
|
* Let the request finish its normal course, suppressing any callbacks.
|
|
@@ -297,6 +215,101 @@ struct Request {
|
|
|
297
215
|
|
|
298
216
|
/** Increment refcount */
|
|
299
217
|
void incref() { refcount++; }
|
|
218
|
+
|
|
219
|
+
lcb_t instance; /**< Library handle */
|
|
220
|
+
std::string url; /**<Base URL: http://host:port/path?query*/
|
|
221
|
+
std::string host; /**< Host, derived from URL */
|
|
222
|
+
std::string port; /**< Port, derived from URL */
|
|
223
|
+
|
|
224
|
+
std::string pending_redirect; /**< New redirected URL */
|
|
225
|
+
|
|
226
|
+
const std::vector<char> body; /**< Input body (for POST/PUT) */
|
|
227
|
+
|
|
228
|
+
/** Request buffer (excluding body). Reassembled from inputs */
|
|
229
|
+
std::vector<char> preamble;
|
|
230
|
+
|
|
231
|
+
struct http_parser_url url_info; /**< Parser info for the URL */
|
|
232
|
+
const lcb_http_method_t method; /**< Request method constant */
|
|
233
|
+
const bool chunked; /**< Whether to invoke callback for each data chunk */
|
|
234
|
+
bool paused; /**< See pause() and resume() */
|
|
235
|
+
const void * const command_cookie; /** User context for callback */
|
|
236
|
+
size_t refcount; /** Initialized to 1. See incref() and decref() */
|
|
237
|
+
int redircount; /** Times this request was redirected */
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Whether this request has delivered data to the user. This is relevant
|
|
241
|
+
* in cases where a retry is requested. If any data has been passed at
|
|
242
|
+
* all, we cannot retry the request.
|
|
243
|
+
*/
|
|
244
|
+
bool passed_data;
|
|
245
|
+
|
|
246
|
+
/** Sparse map indicating which nodes the request was already sent to */
|
|
247
|
+
std::vector<int> used_nodes;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Last revision ID of vBucket config. If the current revision does not
|
|
251
|
+
* match this number, the ::used_nodes field is cleared
|
|
252
|
+
*/
|
|
253
|
+
int last_vbcrev;
|
|
254
|
+
|
|
255
|
+
const lcb_http_type_t reqtype; /**< HTTP API type */
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
enum State {
|
|
259
|
+
/**
|
|
260
|
+
* The request is still ongoing. Callbacks are still active.
|
|
261
|
+
* Note that this essentially means the absence of any flags :)
|
|
262
|
+
*/
|
|
263
|
+
ONGOING = 0,
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* This flag is set when the on_complete callback has been invoked. This
|
|
267
|
+
* is used as a marker to prevent us from calling that callback more than
|
|
268
|
+
* once per request
|
|
269
|
+
*/
|
|
270
|
+
CBINVOKED = 1 << 0,
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* This flag is set by lcb_http_request_finish, and indicates that the
|
|
274
|
+
* request is no longer active per se. This means that while the request
|
|
275
|
+
* may still be valid in memory, it is simply waiting for any pending I/O
|
|
276
|
+
* operations to close, so the reference count can hit zero.
|
|
277
|
+
*/
|
|
278
|
+
FINISHED = 1 << 1,
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Internal flag used to indicate that finish() should not not attempt
|
|
282
|
+
* to modify any instance-level globals. This is currently used
|
|
283
|
+
* from within lcb_destroy()
|
|
284
|
+
*/
|
|
285
|
+
NOLCB = 1 << 2
|
|
286
|
+
};
|
|
287
|
+
int status; /**< OR'd flags of ::State */
|
|
288
|
+
std::vector<Header> request_headers; /**< List of request headers */
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Response headers for callback (array of char*). Buffers are mapped to
|
|
292
|
+
* ::response_headers
|
|
293
|
+
*/
|
|
294
|
+
std::vector<const char*> response_headers_clist;
|
|
295
|
+
|
|
296
|
+
/** Backing buffers for response headers */
|
|
297
|
+
std::vector<lcb::htparse::MimeHeader> response_headers;
|
|
298
|
+
|
|
299
|
+
/** Callback to invoke */
|
|
300
|
+
lcb_RESPCALLBACK callback;
|
|
301
|
+
|
|
302
|
+
// IO variables
|
|
303
|
+
lcbio_pTABLE io;
|
|
304
|
+
lcbio_pCTX ioctx;
|
|
305
|
+
lcbio_pTIMER timer;
|
|
306
|
+
lcbio_CONNREQ creq;
|
|
307
|
+
|
|
308
|
+
/** HTTP Protocol parser */
|
|
309
|
+
lcb::htparse::Parser* parser;
|
|
310
|
+
|
|
311
|
+
/** overrides default timeout if nonzero */
|
|
312
|
+
const uint32_t user_timeout;
|
|
300
313
|
};
|
|
301
314
|
|
|
302
315
|
} // namespace: http
|
|
@@ -43,7 +43,7 @@ Request::decref()
|
|
|
43
43
|
close_io();
|
|
44
44
|
|
|
45
45
|
if (parser) {
|
|
46
|
-
|
|
46
|
+
delete parser;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (timer) {
|
|
@@ -103,7 +103,6 @@ void
|
|
|
103
103
|
Request::maybe_refresh_config(lcb_error_t err)
|
|
104
104
|
{
|
|
105
105
|
int htstatus_ok;
|
|
106
|
-
lcbht_RESPONSE *resp;
|
|
107
106
|
if (!parser) {
|
|
108
107
|
return;
|
|
109
108
|
}
|
|
@@ -112,25 +111,25 @@ Request::maybe_refresh_config(lcb_error_t err)
|
|
|
112
111
|
return;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
resp =
|
|
116
|
-
htstatus_ok = resp
|
|
114
|
+
const lcb::htparse::Response& resp = parser->get_cur_response();
|
|
115
|
+
htstatus_ok = resp.status >= 200 && resp.status < 299;
|
|
117
116
|
|
|
118
117
|
if (err != LCB_SUCCESS && (err == LCB_ESOCKSHUTDOWN && htstatus_ok) == 0) {
|
|
119
118
|
/* ignore graceful close */
|
|
120
|
-
|
|
119
|
+
instance->bootstrap(BS_REFRESH_ALWAYS);
|
|
121
120
|
return;
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
if (htstatus_ok) {
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
127
|
-
|
|
126
|
+
instance->bootstrap(BS_REFRESH_ALWAYS);
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
void
|
|
131
130
|
Request::init_resp(lcb_RESPHTTP *res)
|
|
132
131
|
{
|
|
133
|
-
const
|
|
132
|
+
const lcb::htparse::Response& htres = parser->get_cur_response();
|
|
134
133
|
|
|
135
134
|
res->cookie = const_cast<void*>(command_cookie);
|
|
136
135
|
res->key = url.c_str() + url_info.field_data[UF_PATH].off;
|
|
@@ -139,9 +138,7 @@ Request::init_resp(lcb_RESPHTTP *res)
|
|
|
139
138
|
if (!response_headers.empty()) {
|
|
140
139
|
res->headers = &response_headers_clist[0];
|
|
141
140
|
}
|
|
142
|
-
|
|
143
|
-
res->htstatus = htres->status;
|
|
144
|
-
}
|
|
141
|
+
res->htstatus = htres.status;
|
|
145
142
|
}
|
|
146
143
|
|
|
147
144
|
void
|
|
@@ -254,9 +251,9 @@ Request::submit()
|
|
|
254
251
|
// Only wipe old parser/response information if current I/O request
|
|
255
252
|
// was a success
|
|
256
253
|
if (parser) {
|
|
257
|
-
|
|
254
|
+
parser->reset();
|
|
258
255
|
} else {
|
|
259
|
-
parser =
|
|
256
|
+
parser = new lcb::htparse::Parser(instance->settings);
|
|
260
257
|
}
|
|
261
258
|
response_headers.clear();
|
|
262
259
|
response_headers_clist.clear();
|
|
@@ -613,23 +610,6 @@ Request::cancel()
|
|
|
613
610
|
finish(LCB_SUCCESS);
|
|
614
611
|
}
|
|
615
612
|
|
|
616
|
-
// Wrappers
|
|
617
|
-
void lcb_htreq_setcb(lcb_http_request_t req, lcb_RESPCALLBACK callback) {
|
|
618
|
-
req->callback = callback;
|
|
619
|
-
}
|
|
620
|
-
void lcb_htreq_block_callback(lcb_http_request_t req) {
|
|
621
|
-
req->block_callback();
|
|
622
|
-
}
|
|
623
|
-
void lcb_htreq_pause(lcb_http_request_t req) {
|
|
624
|
-
req->pause();
|
|
625
|
-
}
|
|
626
|
-
void lcb_htreq_resume(lcb_http_request_t req) {
|
|
627
|
-
req->resume();
|
|
628
|
-
}
|
|
629
|
-
void lcb_htreq_finish(lcb_t, lcb_http_request_t req, lcb_error_t rc) {
|
|
630
|
-
req->finish(rc);
|
|
631
|
-
}
|
|
632
|
-
|
|
633
613
|
LIBCOUCHBASE_API
|
|
634
614
|
void
|
|
635
615
|
lcb_cancel_http_request(lcb_t, lcb_http_request_t req)
|
|
@@ -1,34 +1 @@
|
|
|
1
|
-
#
|
|
2
|
-
#define LCB_HTTPAPI_H
|
|
3
|
-
|
|
4
|
-
/* This file contains the internal API for HTTP requests. This allows us to
|
|
5
|
-
* change the internals without exposing the object structure to the rest
|
|
6
|
-
* of the library
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
#ifdef __cplusplus
|
|
10
|
-
extern "C" {
|
|
11
|
-
#endif
|
|
12
|
-
|
|
13
|
-
void
|
|
14
|
-
lcb_htreq_setcb(lcb_http_request_t, lcb_RESPCALLBACK);
|
|
15
|
-
|
|
16
|
-
void
|
|
17
|
-
lcb_htreq_pause(lcb_http_request_t);
|
|
18
|
-
|
|
19
|
-
void
|
|
20
|
-
lcb_htreq_resume(lcb_http_request_t);
|
|
21
|
-
|
|
22
|
-
void
|
|
23
|
-
lcb_htreq_finish(lcb_t, lcb_http_request_t, lcb_error_t);
|
|
24
|
-
|
|
25
|
-
/* Prevents the callback from being invoked. This is different than a full
|
|
26
|
-
* destruction of the object. This is only called in lcb_destroy() to
|
|
27
|
-
* prevent dereferencing the instance itself.
|
|
28
|
-
*/
|
|
29
|
-
void
|
|
30
|
-
lcb_htreq_block_callback(lcb_http_request_t);
|
|
31
|
-
#ifdef __cplusplus
|
|
32
|
-
}
|
|
33
|
-
#endif
|
|
34
|
-
#endif
|
|
1
|
+
#include "http-priv.h"
|