Unverified Commit b95456f4 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

mime: acknowledge CURL_DISABLE_MIME

parent 0e2208ad
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -24,14 +24,14 @@


#include <curl/curl.h>
#include <curl/curl.h>


#ifndef CURL_DISABLE_HTTP
#include "formdata.h"
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)


#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
#include <libgen.h>
#include <libgen.h>
#endif
#endif


#include "urldata.h" /* for struct Curl_easy */
#include "urldata.h" /* for struct Curl_easy */
#include "formdata.h"
#include "mime.h"
#include "mime.h"
#include "non-ascii.h"
#include "non-ascii.h"
#include "vtls/vtls.h"
#include "vtls/vtls.h"
@@ -921,7 +921,8 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
  return result;
  return result;
}
}


#else  /* CURL_DISABLE_HTTP */
#else
/* if disabled */
CURLFORMcode curl_formadd(struct curl_httppost **httppost,
CURLFORMcode curl_formadd(struct curl_httppost **httppost,
                          struct curl_httppost **last_post,
                          struct curl_httppost **last_post,
                          ...)
                          ...)
@@ -946,5 +947,4 @@ void curl_formfree(struct curl_httppost *form)
  /* does nothing HTTP is disabled */
  /* does nothing HTTP is disabled */
}
}



#endif  /* if disabled */
#endif  /* !defined(CURL_DISABLE_HTTP) */
+10 −1
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *                             \___|\___/|_| \_\_____|
 *
 *
 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 *
 * This software is licensed as described in the file COPYING, which
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * you should have received as part of this distribution. The terms
@@ -22,6 +22,10 @@
 *
 *
 ***************************************************************************/
 ***************************************************************************/


#include "curl_setup.h"

#ifndef CURL_DISABLE_MIME

/* used by FormAdd for temporary storage */
/* used by FormAdd for temporary storage */
typedef struct FormInfo {
typedef struct FormInfo {
  char *name;
  char *name;
@@ -47,5 +51,10 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
                          curl_mimepart *,
                          curl_mimepart *,
                          struct curl_httppost *post,
                          struct curl_httppost *post,
                          curl_read_callback fread_func);
                          curl_read_callback fread_func);
#else
/* disabled */
#define Curl_getformdata(a,b,c,d) CURLE_NOT_BUILT_IN
#endif



#endif /* HEADER_CURL_FORMDATA_H */
#endif /* HEADER_CURL_FORMDATA_H */
+4 −0
Original line number Original line Diff line number Diff line
@@ -2174,6 +2174,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
    http->sendit = NULL;
    http->sendit = NULL;
  }
  }


#ifndef CURL_DISABLE_MIME
  if(http->sendit) {
  if(http->sendit) {
    const char *cthdr = Curl_checkheaders(conn, "Content-Type");
    const char *cthdr = Curl_checkheaders(conn, "Content-Type");


@@ -2198,6 +2199,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
      return result;
      return result;
    http->postsize = Curl_mime_size(http->sendit);
    http->postsize = Curl_mime_size(http->sendit);
  }
  }
#endif


  ptr = Curl_checkheaders(conn, "Transfer-Encoding");
  ptr = Curl_checkheaders(conn, "Transfer-Encoding");
  if(ptr) {
  if(ptr) {
@@ -2766,6 +2768,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
        return result;
        return result;
    }
    }


#ifndef CURL_DISABLE_MIME
    /* Output mime-generated headers. */
    /* Output mime-generated headers. */
    {
    {
      struct curl_slist *hdr;
      struct curl_slist *hdr;
@@ -2776,6 +2779,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
          return result;
          return result;
      }
      }
    }
    }
#endif


    /* For really small posts we don't use Expect: headers at all, and for
    /* For really small posts we don't use Expect: headers at all, and for
       the somewhat bigger ones we allow the app to disable it. Just make
       the somewhat bigger ones we allow the app to disable it. Just make
+3 −71
Original line number Original line Diff line number Diff line
@@ -29,8 +29,8 @@
#include "urldata.h"
#include "urldata.h"
#include "sendf.h"
#include "sendf.h"


#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
    !defined(CURL_DISABLE_IMAP)
  !defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)


#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
#include <libgen.h>
#include <libgen.h>
@@ -1901,72 +1901,4 @@ CURLcode curl_mime_headers(curl_mimepart *part,
  return CURLE_NOT_BUILT_IN;
  return CURLE_NOT_BUILT_IN;
}
}


void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
#endif /* if disabled */
{
  (void) part;
  (void) easy;
}

void Curl_mime_cleanpart(curl_mimepart *part)
{
  (void) part;
}

CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
{
  (void) dst;
  (void) src;
  return CURLE_OK;    /* Nothing to duplicate: always succeed. */
}

CURLcode Curl_mime_set_subparts(curl_mimepart *part,
                                curl_mime *subparts, int take_ownership)
{
  (void) part;
  (void) subparts;
  (void) take_ownership;
  return CURLE_NOT_BUILT_IN;
}

CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
                                   const char *contenttype,
                                   const char *disposition,
                                   enum mimestrategy strategy)
{
  (void) part;
  (void) contenttype;
  (void) disposition;
  (void) strategy;
  return CURLE_NOT_BUILT_IN;
}

curl_off_t Curl_mime_size(curl_mimepart *part)
{
  (void) part;
  return (curl_off_t) -1;
}

size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream)
{
  (void) buffer;
  (void) size;
  (void) nitems;
  (void) instream;
  return 0;
}

CURLcode Curl_mime_rewind(curl_mimepart *part)
{
  (void) part;
  return CURLE_NOT_BUILT_IN;
}

/* VARARGS2 */
CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
{
  (void) slp;
  (void) fmt;
  return CURLE_NOT_BUILT_IN;
}

#endif /* !CURL_DISABLE_HTTP || !CURL_DISABLE_SMTP || !CURL_DISABLE_IMAP */
+19 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@
 *
 *
 ***************************************************************************/
 ***************************************************************************/


#include "curl_setup.h"

#define MIME_RAND_BOUNDARY_CHARS        16  /* Nb. of random boundary chars. */
#define MIME_RAND_BOUNDARY_CHARS        16  /* Nb. of random boundary chars. */
#define MAX_ENCODED_LINE_LENGTH         76  /* Maximum encoded line length. */
#define MAX_ENCODED_LINE_LENGTH         76  /* Maximum encoded line length. */
#define ENCODING_BUFFER_SIZE            256 /* Encoding temp buffers size. */
#define ENCODING_BUFFER_SIZE            256 /* Encoding temp buffers size. */
@@ -125,6 +127,8 @@ struct curl_mimepart_s {
  mime_encoder_state encstate;     /* Data encoder state. */
  mime_encoder_state encstate;     /* Data encoder state. */
};
};


#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
  !defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)


/* Prototypes. */
/* Prototypes. */
void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy);
void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy);
@@ -143,4 +147,18 @@ CURLcode Curl_mime_rewind(curl_mimepart *part);
CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
const char *Curl_mime_contenttype(const char *filename);
const char *Curl_mime_contenttype(const char *filename);


#else
/* if disabled */
#define Curl_mime_initpart(x,y)
#define Curl_mime_cleanpart(x)
#define Curl_mime_duppart(x,y) CURLE_OK /* Nothing to duplicate. Succeed */
#define Curl_mime_set_subparts(a,b,c) CURLE_NOT_BUILT_IN
#define Curl_mime_prepare_headers(a,b,c,d) CURLE_NOT_BUILT_IN
#define Curl_mime_size(x) (curl_off_t) -1
#define Curl_mime_read NULL
#define Curl_mime_rewind(x) ((void)x, CURLE_NOT_BUILT_IN)
#define Curl_mime_add_header(x,y,...) CURLE_NOT_BUILT_IN
#endif


#endif /* HEADER_CURL_MIME_H */
#endif /* HEADER_CURL_MIME_H */