changeset 304:95bcb77d62c1

2003-11-2 Brian Masney <masneyb@gftp.org> * lib/rfc2068.c (rfc2068_get_file) - if there is any data in the current read buffer, grab that data first. Otherwise, read from the socket.
author masneyb
date Mon, 03 Nov 2003 02:35:18 +0000
parents 3b9d5797050f
children 6d180e6a8ba5
files ChangeLog lib/rfc2068.c
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Nov 03 02:14:05 2003 +0000
+++ b/ChangeLog	Mon Nov 03 02:35:18 2003 +0000
@@ -1,4 +1,7 @@
 2003-11-2 Brian Masney <masneyb@gftp.org>
+	* lib/rfc2068.c (rfc2068_get_file) - if there is any data in the current
+	read buffer, grab that data first. Otherwise, read from the socket.
+
 	* lib/rfc2068.c (rfc2068_chunked_read) - more improvements to this
 	function so that it will parse more chunked file transfers correctly.
 
@@ -1672,7 +1675,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.164 2003/11/03 02:11:16 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.165 2003/11/03 02:35:18 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/rfc2068.c	Mon Nov 03 02:14:05 2003 +0000
+++ b/lib/rfc2068.c	Mon Nov 03 02:35:18 2003 +0000
@@ -354,11 +354,23 @@
   g_return_val_if_fail (request->protonum == GFTP_HTTP_NUM, GFTP_EFATAL);
 
   params = request->protocol_data;
+  if (params->rbuf != NULL && params->rbuf->curpos != NULL)
+    {
+      len = params->rbuf->cur_bufsize > size ? size : params->rbuf->cur_bufsize;
+      memcpy (buf, params->rbuf->curpos, len);
 
-  if ((len = request->read_function (request, buf, size, request->datafd)) < 0)
-    return ((ssize_t) len);
+      if (len == params->rbuf->cur_bufsize)
+        gftp_free_getline_buffer (&params->rbuf);
+      else
+        {
+          params->rbuf->curpos += len;
+          params->rbuf->cur_bufsize -= len;
+        }
 
-  return (len);
+      return (len);
+    }
+
+  return (request->read_function (request, buf, size, request->datafd));
 }