src/server/util/io.h

branch
webdav
changeset 333
bb536d4bc174
parent 193
aa8393527b1e
child 334
a55491f66003
--- a/src/server/util/io.h	Thu May 05 21:46:10 2022 +0200
+++ b/src/server/util/io.h	Fri May 06 22:45:53 2022 +0200
@@ -89,13 +89,24 @@
 #endif
 };
 
+#define HTTP_STREAM_CBUF_SIZE 16
 struct HttpStream {
     IOStream st;
     IOStream *fd;
     uint64_t max_read;
     uint64_t read;
+    uint64_t read_total;
+    char     *readbuf;
+    size_t   bufsize; // allocated buffer size
+    size_t   buflen;  // currently number of bytes in the buffer
+    int      *bufpos; // current buffer position
+    int      chunk_buf_pos;
+    char     chunk_buf[HTTP_STREAM_CBUF_SIZE];
+    char     remaining_buf[HTTP_STREAM_CBUF_SIZE];
+    int      remaining_len;
+    int      remaining_pos;
     WSBool   chunked_enc;
-    WSBool   buffered;
+    WSBool   read_eof;
 };
 
 typedef struct SSLStream {
@@ -120,9 +131,14 @@
 /* http stream */
 IOStream* httpstream_new(pool_handle_t *pool, IOStream *fd);
 
+int httpstream_enable_chunked_read(IOStream *st, char *buffer, size_t bufsize, int *cursize, int *pos);
+int httpstream_enable_chunked_write(IOStream *st);
+int httpstream_set_max_read(IOStream *st, int64_t maxread);
+
 ssize_t net_http_write(HttpStream *st, void *buf, size_t nbytes);
 ssize_t net_http_writev(HttpStream *st, struct iovec *iovec, int iovcnt);
 ssize_t net_http_read(HttpStream *st, void *buf, size_t nbytes);
+ssize_t net_http_read_chunked(HttpStream *st, void *buf, size_t nbytes);
 ssize_t net_http_sendfile(HttpStream *st, sendfiledata *sfd);
 void    net_http_close(HttpStream *st);
 void    net_http_finish(HttpStream *st);

mercurial