+
+int
+read_serv_chunk(
+
+ StrBuf *Buf,
+ size_t total_len,
+ size_t *bytes_read
+ )
+{
+ int rc;
+ int ServerRc;
+ wcsession *WCC = WC;
+
+ serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, *bytes_read, total_len-(*bytes_read));
+ if ( (rc = StrBuf_ServGetln(Buf) > 0) &&
+ (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6) )
+ {
+ size_t this_block = 0;
+
+ if (rc < 0)
+ return rc;
+
+ StrBufCutLeft(Buf, 4);
+ this_block = StrTol(Buf);
+ rc = StrBuf_ServGetBLOBBuffered(WCC->WBuf, this_block);
+ if (rc < 0) {
+ syslog(LOG_INFO, "Server connection broken during download\n");
+ wc_backtrace(LOG_INFO);
+ if (WCC->serv_sock > 0) close(WCC->serv_sock);
+ WCC->serv_sock = (-1);
+ WCC->connected = 0;
+ WCC->logged_in = 0;
+ return rc;
+ }
+ *bytes_read += rc;
+ }
+ return 6;
+}
+
+static inline int send_http(StrBuf *Buf)
+{
+#ifdef HAVE_OPENSSL
+ if (is_https)
+ return client_write_ssl(Buf);
+ else
+#endif
+ return client_write(Buf);
+}