1 --- elinks/src/protocol/http/http.c Sun Dec 22 12:52:20 2002
2 +++ elinks.2/src/protocol/http/http.c Tue Dec 24 22:15:59 2002
4 /* Number of uncompressed bytes that could be safely get from
5 * read_encoded(). We can't want to read too much, because if gzread
6 * "clears" the buffer next time it will return -1. */
9 int r = 0, *length_of_block;
10 - /* If true, all stuff was written to pipe and only uncompression is
13 unsigned char *output = NULL;
15 length_of_block = (info->length == LEN_CHUNKED ? &info->chunk_remaining
17 - if (!*length_of_block) finishing = 1;
18 + if (!*length_of_block)
21 if (conn->content_encoding == ENCODING_NONE) {
24 || set_nonblocking_fd(conn->stream_pipes[1]) < 0))
29 - int written = write(conn->stream_pipes[1], data, len);
32 + int written = write(conn->stream_pipes[1], data, len > ret ? ret : len);
34 /* When we're writing zero bytes already, we want to
35 * zero ret properly for now, so that we'll go out for
37 * zero bytes, but ret will be on its original value,
38 * causing us to close the stream, and that's disaster
39 * when more data are about to come yet. */
40 - if (written > 0 || (!written && !len)) {
47 if (*length_of_block > 0)
48 - *length_of_block -= ret;
49 + *length_of_block -= written;
58 - /* We assume that this is because full pipe. */
59 - /* FIXME: We should probably handle errors as
61 - ret = 4096; /* pipe capacity */
64 - /* finishing could be changed above ;) */
66 - /* Granularity of the final decompression. When we were
67 - * taking the decompressed content, we only took the
68 - * amount which we inserted there. When finishing, we
69 - * have to drain the rest from the beast. */
70 - /* TODO: We should probably double the ret before trying
71 - * to read as well..? Would maybe make the progressive
72 - * displaying feeling better? --pasky */
76 - /* Not enough data, try in next round. */
84 r = read_encoded(conn->stream, output + *new_len, ret);
86 if (r > 0) *new_len += r;
88 + } while (len || r == ret);
90 if (r < 0 && output) {