src/server/util/io.c

branch
webdav
changeset 235
4990147c58d0
parent 205
b8515afa450a
child 251
f727a21497bb
equal deleted inserted replaced
234:f30740c3aafb 235:4990147c58d0
267 io[0].iov_len = snprintf(chunk_len, 16, "%zx\r\n", nbytes); 267 io[0].iov_len = snprintf(chunk_len, 16, "%zx\r\n", nbytes);
268 io[1].iov_base = buf; 268 io[1].iov_base = buf;
269 io[1].iov_len = nbytes; 269 io[1].iov_len = nbytes;
270 io[2].iov_base = "\r\n"; 270 io[2].iov_base = "\r\n";
271 io[2].iov_len = 2; 271 io[2].iov_len = 2;
272 // TODO: FIXME: if r < sum of iov_len, everything would explode
273 // we need to store the chunk state and remaining bytes
272 ssize_t r = fd->writev(fd, io, 3); 274 ssize_t r = fd->writev(fd, io, 3);
273 return r - io[0].iov_len; 275 return r - io[0].iov_len - io[2].iov_len;
274 } else { 276 } else {
275 return fd->write(fd, buf, nbytes); 277 return fd->write(fd, buf, nbytes);
276 } 278 }
277 } 279 }
278 280

mercurial