splitted write and flush to reduce syscall in http