/*
+--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
+ | libmemcached-awesome - C/C++ Client Library for memcached |
+--------------------------------------------------------------------+
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted under the terms of the BSD license. |
| the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+--------------------------------------------------------------------+
| Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ |
+--------------------------------------------------------------------+
*/
#include "libmemcachedprotocol/common.h"
+#include "p9y/socket.hpp"
#include <stdlib.h>
#include <sys/types.h>
protocol_binary_response_header *response) {
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->pedantic
+ if (response && client->root->pedantic
&& !memcached_binary_protocol_pedantic_check_response(request, response)) {
return PROTOCOL_BINARY_RESPONSE_EINVAL;
}
return PROTOCOL_BINARY_RESPONSE_EINTERNAL;
}
+ if (!response) {
+ return PROTOCOL_BINARY_RESPONSE_SUCCESS;
+ }
+
size_t len = sizeof(protocol_binary_response_header) + htonl(response->response.bodylen);
size_t offset = 0;
char *ptr = (void *) response;
rval = client->root->callback->interface.v1.stat(cookie, (void *) (header + 1), keylen,
stat_response_handler);
+ if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
+ /* END message */
+ protocol_binary_response_no_extras response = {
+ .message = {
+ .header.response =
+ {
+ .magic = PROTOCOL_BINARY_RES,
+ .opcode = PROTOCOL_BINARY_CMD_STAT,
+ .status = htons(PROTOCOL_BINARY_RESPONSE_SUCCESS),
+ .opaque = header->request.opaque,
+ },
+ }};
+ rval = response_handler(cookie, header, (void *) &response);
+ }
} else {
rval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}
memcached_protocol_client_st *client = (void *) cookie;
if (client->root->callback->interface.v1.version) {
rval = client->root->callback->interface.v1.version(cookie, version_response_handler);
+ if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
+ rval = response_handler(cookie, header, NULL);
+ }
} else {
rval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}