1 --- elinks-0.4.0/src/protocol/http/http.c Sat Dec 7 23:15:31 2002
2 +++ elinks-0.4.0.new/src/protocol/http/http.c Tue Dec 24 21:26:46 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. */
8 - int r = 0, *length_of_block;
10 + int r, *length_of_block;
11 /* If true, all stuff was written to pipe and only uncompression is
15 if (set_nonblocking_fd(conn->stream_pipes[1]) < 0) return NULL;
21 - int written = write(conn->stream_pipes[1], data, len);
23 + int written = write(conn->stream_pipes[1], data, len > 2048 ? 2048 : len);
24 /* When we're writing zero bytes already, we want to
25 * zero ret properly for now, so that we'll go out for
26 * some more data. Otherwise, read_encoded() will yield
28 * causing us to close the stream, and that's disaster
29 * when more data are about to come yet. */
30 if (written > 0 || (!written && !len)) {
34 - if (*length_of_block > 0)
35 - *length_of_block -= ret;
38 + *length_of_block -= written;
44 - /* We assume that this is because full pipe. */
45 - /* FIXME: We should probably handle errors as
47 - ret = 4096; /* pipe capacity */
53 /* finishing could be changed above ;) */
55 /* Granularity of the final decompression. When we were
57 * displaying feeling better? --pasky */
61 - /* Not enough data, try in next round. */
66 conn->stream = open_encoded(conn->stream_pipes[0],
68 output = (unsigned char *) mem_realloc(output, *new_len + ret);
71 - r = read_encoded(conn->stream, output + *new_len, ret);
72 + r = read_encoded(conn->stream, output + *new_len, ret);
73 if (r > 0) *new_len += r;
75 + } while (len || r == ret);
77 if (r < 0 && output) {