mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-27 20:48:29 +00:00
Fixed iterate_callback()
This commit is contained in:
1 parent
03e737829a
commit
58d3abe165
1 file changed
+4
-3
+4
-3
@@ -1206,13 +1206,12 @@ static void send_continue_if_expected(struct connection *conn) {
|
|||||||
static void process_request(struct connection *conn) {
|
static void process_request(struct connection *conn) {
|
||||||
struct iobuf *io = &conn->local_iobuf;
|
struct iobuf *io = &conn->local_iobuf;
|
||||||
|
|
||||||
//DBG(("parse_http_message(%d [%.*s])", io->len, io->len, io->buf));
|
|
||||||
if (conn->request_len == 0 &&
|
if (conn->request_len == 0 &&
|
||||||
(conn->request_len = get_request_len((unsigned char *) io->buf,
|
(conn->request_len = get_request_len((unsigned char *) io->buf,
|
||||||
io->len)) > 0) {
|
io->len)) > 0) {
|
||||||
// If request is buffered in, remove it from the iobuf. This is because
|
// If request is buffered in, remove it from the iobuf. This is because
|
||||||
// iobuf could be reallocated, and pointers in parsed request could
|
// iobuf could be reallocated, and pointers in parsed request could
|
||||||
// become ivalid.
|
// become invalid.
|
||||||
conn->request = (char *) malloc(conn->request_len);
|
conn->request = (char *) malloc(conn->request_len);
|
||||||
memcpy(conn->request, io->buf, conn->request_len);
|
memcpy(conn->request, io->buf, conn->request_len);
|
||||||
memmove(io->buf, io->buf + conn->request_len, io->len - conn->request_len);
|
memmove(io->buf, io->buf + conn->request_len, io->len - conn->request_len);
|
||||||
@@ -1477,7 +1476,9 @@ struct mg_server *mg_create_server(void *server_data) {
|
|||||||
|
|
||||||
static void iterate_callback(struct mg_connection *c, void *param) {
|
static void iterate_callback(struct mg_connection *c, void *param) {
|
||||||
if (c->connection_param != NULL) {
|
if (c->connection_param != NULL) {
|
||||||
mg_write(c, "%d", * (int *) param);
|
char buf[20];
|
||||||
|
int len = snprintf(buf, sizeof(buf), "%d", * (int *) param);
|
||||||
|
mg_write(c, buf, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user