Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

C++ make_http_request not functioning

2 replies [Last post]
  • Login or register to post comments
Mon, 01/14/2013 - 21:26
simy307
Offline
Joined: 01/12/2013
Groups: None

I am using some of the example documents to try and retrieve a view from couchbase. I am using C++ and Couchbase 2.0.

I am using the following:

static void complete_callback(lcb_http_request_t request,lcb_t instance, const void *cookie, lcb_error_t error,const lcb_http_resp_t *resp)
{
    const void *buffer3 = resp->v.v0.bytes;
    const char *temp3 = (const char *)buffer3;
    //At this point I have checked and there is nothing being stored and resp as no data in "bytes"
}
 
int main()
{
...
   (void)lcb_set_http_complete_callback(instance, complete_callback);
   lcb_error_t rc;
   lcb_http_cmd_t cmd  ;
   cmd.version = 0;
   cmd.v.v0.path = "_design/getKeys/_view/getKeys?limit=10";
   cmd.v.v0.npath = strlen(cmd.v.v0.path);
   cmd.v.v0.body = NULL;
   cmd.v.v0.nbody = 0;
   cmd.v.v0.method = LCB_HTTP_METHOD_GET;
   cmd.v.v0.chunked = 1;
   cmd.v.v0.content_type = "application/json";
   rc = lcb_make_http_request(instance, NULL, LCB_HTTP_TYPE_VIEW, &cmd, NULL);
   lcb_wait(instance);
...
}

I have successfully added and removed documents from the bucket. However when running the code above I receive no data. Even using a debugger I can see that "resp" has nothing in "bytes". In couchbase I have made a view and published it. I am able to view results through a web-browser using the "_design/getKeys/_view/getKeys?limit=10" path. However, I am able to see a read from the server. Any help and definitely advice would be greatly appreciated.

Top
  • Login or register to post comments
Tue, 01/15/2013 - 06:53
avsej
avsej's picture
Offline
Joined: 06/15/2011
Groups: None

Obviously you have two options:

1) define data_callback in conjunction to complete_callback, then you will receive chunks with data callback and complete callback will be triggered after the end of stream

2) set cmd.v.v0.chunked to zero, this will force libcouchbase to collect all chunks and emit them as a whole in complete_callback

This behaviour is documented here: https://github.com/couchbase/libcouchbase/blob/master/include/libcouchba...

__________________

Find me on FreeNode IRC in #libcouchbase channel

Top
  • Login or register to post comments
Wed, 01/16/2013 - 00:24
simy307
Offline
Joined: 01/12/2013
Groups: None

Thank you that worked!

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker