mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-25 20:28:27 +00:00
Fixed problem with mg_printf_data()
This commit is contained in:
1 parent
c39a712540
commit
9bbf4c8384
1 file changed
+14
-7
+14
-7
@@ -2256,19 +2256,26 @@ void mg_printf_data(struct mg_connection *c, const char *fmt, ...) {
|
|||||||
struct connection *conn = MG_CONN_2_CONN(c);
|
struct connection *conn = MG_CONN_2_CONN(c);
|
||||||
struct iobuf *io = &conn->ns_conn->send_iobuf;
|
struct iobuf *io = &conn->ns_conn->send_iobuf;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
static const char chunk_len[] = " \r\n";
|
int len, n;
|
||||||
int len, n, cl = sizeof(chunk_len) - 1;
|
char *p;
|
||||||
char *p, buf[9];
|
|
||||||
|
|
||||||
terminate_headers(c);
|
terminate_headers(c);
|
||||||
|
|
||||||
|
// Write the placeholder for the chunk size
|
||||||
|
p = io->buf + io->len;
|
||||||
|
iobuf_append(io, " \r\n", 10);
|
||||||
|
|
||||||
|
// Write chunk itself
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
ns_send(conn->ns_conn, chunk_len, cl);
|
|
||||||
p = io->buf + io->len - cl;
|
|
||||||
len = ns_vprintf(conn->ns_conn, fmt, ap);
|
len = ns_vprintf(conn->ns_conn, fmt, ap);
|
||||||
n = mg_snprintf(buf, sizeof(buf), "%X", len);
|
|
||||||
memcpy(p, buf, n < 9 ? n : 8);
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
// Record size
|
||||||
|
n = mg_snprintf(p, 7, "%X", len);
|
||||||
|
p[n] = ' ';
|
||||||
|
|
||||||
|
// Write terminating new line
|
||||||
|
mg_write(c, "\r\n", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(MONGOOSE_NO_WEBSOCKET) || !defined(MONGOOSE_NO_AUTH)
|
#if !defined(MONGOOSE_NO_WEBSOCKET) || !defined(MONGOOSE_NO_AUTH)
|
||||||
|
|||||||
Reference in new issue
Block a user