Commit cfdcae4b authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Based on a patch by Armel Asselin, the FTP code no longer re-issues the TYPE

command on subsequent requests on a re-used connection unless it has to.
parent 74a6921b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@
                                  Changelog

Daniel (19 August 2006)
- Based on a patch by Armel Asselin, the FTP code no longer re-issues the TYPE
  command on subsequent requests on a re-used connection unless it has to.

- Armel Asselin fixed a crash in the FTP code when using SINGLECWD mode and
  files in the root directory.

+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ Curl and libcurl 7.15.6

This release includes the following changes:

 o (FTP) libcurl avoids sending TYPE if the desired type was already set
 o CURLOPT_PREQUOTE works even when CURLOPT_NOBODY is set true

This release includes the following bugfixes:
+17 −17
Original line number Diff line number Diff line
@@ -62,9 +62,9 @@ enum zlibState {
};

static CURLcode
process_zlib_error(struct SessionHandle *data,
 z_stream *z)
process_zlib_error(struct connectdata *conn, z_stream *z)
{
  struct SessionHandle *data = conn->data;
  if (z->msg)
    failf (data, "Error while processing content unencoding: %s",
           z->msg);
@@ -84,7 +84,7 @@ exit_zlib(z_stream *z, bool *zlib_init, CURLcode result)
}

static CURLcode
inflate_stream(struct SessionHandle *data,
inflate_stream(struct connectdata *conn,
               struct Curl_transfer_keeper *k)
{
  int allow_restart = 1;
@@ -113,7 +113,7 @@ inflate_stream(struct SessionHandle *data,
    if (status == Z_OK || status == Z_STREAM_END) {
      allow_restart = 0;
      if(DSIZ - z->avail_out) {
        result = Curl_client_write(data, CLIENTWRITE_BODY, decomp,
        result = Curl_client_write(conn, CLIENTWRITE_BODY, decomp,
                                   DSIZ - z->avail_out);
        /* if !CURLE_OK, clean up, return */
        if (result) {
@@ -128,7 +128,7 @@ inflate_stream(struct SessionHandle *data,
        if (inflateEnd(z) == Z_OK)
          return exit_zlib(z, &k->zlib_init, result);
        else
          return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z));
          return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
      }

      /* Done with these bytes, exit */
@@ -143,7 +143,7 @@ inflate_stream(struct SessionHandle *data,

      inflateReset(z);
      if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
        return process_zlib_error(data, z);
        return process_zlib_error(conn, z);
      }
      z->next_in = orig_in;
      z->avail_in = nread;
@@ -152,14 +152,14 @@ inflate_stream(struct SessionHandle *data,
    }
    else {                      /* Error; exit loop, handle below */
      free(decomp);
      return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z));
      return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
    }
  }
  /* Will never get here */
}

CURLcode
Curl_unencode_deflate_write(struct SessionHandle *data,
Curl_unencode_deflate_write(struct connectdata *conn,
                            struct Curl_transfer_keeper *k,
                            ssize_t nread)
{
@@ -173,7 +173,7 @@ Curl_unencode_deflate_write(struct SessionHandle *data,
    z->next_in = NULL;
    z->avail_in = 0;
    if (inflateInit(z) != Z_OK)
      return process_zlib_error(data, z);
      return process_zlib_error(conn, z);
    k->zlib_init = ZLIB_INIT;
  }

@@ -182,7 +182,7 @@ Curl_unencode_deflate_write(struct SessionHandle *data,
  z->avail_in = (uInt)nread;

  /* Now uncompress the data */
  return inflate_stream(data, k);
  return inflate_stream(conn, k);
}

#ifdef OLD_ZLIB_SUPPORT
@@ -272,7 +272,7 @@ static enum {
#endif

CURLcode
Curl_unencode_gzip_write(struct SessionHandle *data,
Curl_unencode_gzip_write(struct connectdata *conn,
                         struct Curl_transfer_keeper *k,
                         ssize_t nread)
{
@@ -289,14 +289,14 @@ Curl_unencode_gzip_write(struct SessionHandle *data,
    if (strcmp(zlibVersion(), "1.2.0.4") >= 0) {
        /* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
        if (inflateInit2(z, MAX_WBITS+32) != Z_OK) {
          return process_zlib_error(data, z);
          return process_zlib_error(conn, z);
        }
        k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */

    } else {
        /* we must parse the gzip header ourselves */
        if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
          return process_zlib_error(data, z);
          return process_zlib_error(conn, z);
        }
        k->zlib_init = ZLIB_INIT;   /* Initial call state */
    }
@@ -307,7 +307,7 @@ Curl_unencode_gzip_write(struct SessionHandle *data,
     z->next_in = (Bytef *)k->str;
     z->avail_in = (uInt)nread;
     /* Now uncompress the data */
     return inflate_stream(data, k);
     return inflate_stream(conn, k);
  }

#ifndef OLD_ZLIB_SUPPORT
@@ -360,7 +360,7 @@ Curl_unencode_gzip_write(struct SessionHandle *data,

    case GZIP_BAD:
    default:
      return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z));
      return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
    }

  }
@@ -398,7 +398,7 @@ Curl_unencode_gzip_write(struct SessionHandle *data,
    case GZIP_BAD:
    default:
      free(z->next_in);
      return exit_zlib(z, &k->zlib_init, process_zlib_error(data, z));
      return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
    }

  }
@@ -418,7 +418,7 @@ Curl_unencode_gzip_write(struct SessionHandle *data,
  }

  /* We've parsed the header, now uncompress the data */
  return inflate_stream(data, k);
  return inflate_stream(conn, k);
#endif
}
#endif /* HAVE_LIBZ */
+3 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -31,11 +31,11 @@
#define ALL_CONTENT_ENCODINGS "identity"
#endif

CURLcode Curl_unencode_deflate_write(struct SessionHandle *data,
CURLcode Curl_unencode_deflate_write(struct connectdata *conn,
                                     struct Curl_transfer_keeper *k,
                                     ssize_t nread);

CURLcode
Curl_unencode_gzip_write(struct SessionHandle *data,
Curl_unencode_gzip_write(struct connectdata *conn,
                         struct Curl_transfer_keeper *k,
                         ssize_t nread);
+4 −4
Original line number Diff line number Diff line
@@ -311,11 +311,11 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
    CURLcode result;
    snprintf(buf, sizeof(data->state.buffer),
             "Content-Length: %" FORMAT_OFF_T "\r\n", expected_size);
    result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
    result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
    if(result)
      return result;

    result = Curl_client_write(data, CLIENTWRITE_BOTH,
    result = Curl_client_write(conn, CLIENTWRITE_BOTH,
                               (char *)"Accept-ranges: bytes\r\n", 0);
    if(result)
      return result;
@@ -339,7 +339,7 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
               tm->tm_hour,
               tm->tm_min,
               tm->tm_sec);
      result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
      result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
    }
    return result;
  }
@@ -377,7 +377,7 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)

    bytecount += nread;

    res = Curl_client_write(data, CLIENTWRITE_BODY, buf, nread);
    res = Curl_client_write(conn, CLIENTWRITE_BODY, buf, nread);
    if(res)
      return res;

Loading