src/server/util/io.h

branch
webdav
changeset 334
a55491f66003
parent 333
bb536d4bc174
child 335
5234c57b8759
equal deleted inserted replaced
333:bb536d4bc174 334:a55491f66003
91 91
92 #define HTTP_STREAM_CBUF_SIZE 16 92 #define HTTP_STREAM_CBUF_SIZE 16
93 struct HttpStream { 93 struct HttpStream {
94 IOStream st; 94 IOStream st;
95 IOStream *fd; 95 IOStream *fd;
96
97 /*
98 * content-length or current chunk size
99 */
96 uint64_t max_read; 100 uint64_t max_read;
101 /*
102 * total bytes read (with content-length) or bytes read of current chunk
103 */
97 uint64_t read; 104 uint64_t read;
105 /*
106 * total bytes read with chunked transfer encoding
107 */
98 uint64_t read_total; 108 uint64_t read_total;
109 /*
110 * read buffer (used only with chunked transfer encoding)
111 */
99 char *readbuf; 112 char *readbuf;
113 /*
114 * readbuf size
115 */
100 size_t bufsize; // allocated buffer size 116 size_t bufsize; // allocated buffer size
117 /*
118 * number of bytes currently stored in readbuf
119 */
101 size_t buflen; // currently number of bytes in the buffer 120 size_t buflen; // currently number of bytes in the buffer
121 /*
122 * current position in the read buffer
123 */
102 int *bufpos; // current buffer position 124 int *bufpos; // current buffer position
125 /*
126 * current chunk_buf position
127 */
103 int chunk_buf_pos; 128 int chunk_buf_pos;
129 /*
130 * buffer used only for parsing chunk headers
131 */
104 char chunk_buf[HTTP_STREAM_CBUF_SIZE]; 132 char chunk_buf[HTTP_STREAM_CBUF_SIZE];
133 /*
134 * after the chunk header is parsed, the content of chunk_buf
135 * will be moved to remaining_buf
136 */
105 char remaining_buf[HTTP_STREAM_CBUF_SIZE]; 137 char remaining_buf[HTTP_STREAM_CBUF_SIZE];
138 /*
139 * number of bytes currently stored in remaining_buf
140 */
106 int remaining_len; 141 int remaining_len;
142 /*
143 *
144 */
107 int remaining_pos; 145 int remaining_pos;
108 WSBool chunked_enc; 146 WSBool chunked_enc;
109 WSBool read_eof; 147 WSBool read_eof;
110 }; 148 };
111 149

mercurial