| 447 | // } |
| 448 | |
| 449 | bool CouchbaseOperations::CouchbaseRequest::selectBucketRequest( |
| 450 | const butil::StringPiece& bucket_name) { |
| 451 | if (bucket_name.empty()) { |
| 452 | DEBUG_PRINT("Empty bucket name"); |
| 453 | return false; |
| 454 | } |
| 455 | // construct the request header |
| 456 | const policy::CouchbaseRequestHeader header = { |
| 457 | policy::CB_MAGIC_REQUEST, |
| 458 | policy::CB_SELECT_BUCKET, |
| 459 | butil::HostToNet16(bucket_name.size()), |
| 460 | 0, |
| 461 | policy::CB_BINARY_RAW_BYTES, |
| 462 | 0, |
| 463 | butil::HostToNet32(bucket_name.size()), |
| 464 | 0, |
| 465 | 0}; |
| 466 | if (_buf.append(&header, sizeof(header))) { |
| 467 | DEBUG_PRINT("Failed to append header to buffer"); |
| 468 | return false; |
| 469 | } |
| 470 | if (_buf.append(bucket_name.data(), bucket_name.size())) { |
| 471 | DEBUG_PRINT("Failed to append bucket name to buffer"); |
| 472 | return false; |
| 473 | } |
| 474 | ++_pipelined_count; |
| 475 | return true; |
| 476 | } |
| 477 | |
| 478 | // HelloRequest sends a Hello request to the Couchbase server, which specifies |
| 479 | // the client features and capabilities. |