Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e2911703
Commit
e2911703
authored
Dec 10, 2018
by
antirez
Browse files
RESP3: verbatim reply API + DEBUG PROTOCOL support.
parent
afba2112
Changes
3
Show whitespace changes
Inline
Side-by-side
src/debug.c
View file @
e2911703
...
...
@@ -576,6 +576,8 @@ NULL
addReplyBool
(
c
,
1
);
}
else
if
(
!
strcasecmp
(
name
,
"false"
))
{
addReplyBool
(
c
,
0
);
}
else
if
(
!
strcasecmp
(
name
,
"verbatim"
))
{
addReplyVerbatim
(
c
,
"This is a verbatim
\n
string"
,
25
,
"txt"
);
}
else
{
addReplyError
(
c
,
"Wrong protocol type name. Please use one of the following: string|integer|double|bignum|null|array|set|map|attrib|push|verbatim|true|false|state|err|bloberr"
);
}
...
...
src/networking.c
View file @
e2911703
...
...
@@ -696,6 +696,35 @@ void addReplyBulkLongLong(client *c, long long ll) {
addReplyBulkCBuffer(c,buf,len);
}
/* Reply with a verbatim type having the specified extension.
*
* The 'ext' is the "extension" of the file, actually just a three
* character type that describes the format of the verbatim string.
* For instance "txt" means it should be interpreted as a text only
* file by the receiver, "md " as markdown, and so forth. Only the
* three first characters of the extension are used, and if the
* provided one is shorter than that, the remaining is filled with
* spaces. */
void addReplyVerbatim(client *c, const char *s, size_t len, const char *ext) {
if (c->resp == 2) {
addReplyBulkCBuffer(c,s,len);
} else {
char buf[32];
size_t preflen = snprintf(buf,sizeof(buf),"=%zu\r\nxxx:",len+4);
char *p = buf+preflen-4;
for (int i = 0; i < 3; i++) {
if (*ext == '\0') {
p[i] = ' ';
} else {
p[i] = *ext++;
}
}
addReplyString(c,buf,preflen);
addReplyString(c,s,len);
addReplyString(c,"\r\n",2);
}
}
/* Add an array of C strings as status replies with a heading.
* This function is typically invoked by from commands that support
* subcommands in response to the 'help' subcommand. The help array
...
...
src/server.h
View file @
e2911703
...
...
@@ -1440,6 +1440,7 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask);
void addReplyNull(client *c);
void addReplyNullArray(client *c);
void addReplyBool(client *c, int b);
void addReplyVerbatim(client *c, const char *s, size_t len, const char *ext);
void addReplyString(client *c, const char *s, size_t len);
void addReplyBulk(client *c, robj *obj);
void addReplyBulkCString(client *c, const char *s);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment