aboutsummaryrefslogtreecommitdiff
path: root/lib/imap.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/imap.c')
-rw-r--r--lib/imap.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/lib/imap.c b/lib/imap.c
index 13e9784a4..c1dffb41d 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -163,7 +163,7 @@ const struct Curl_handler Curl_handler_imaps = {
static const struct Curl_handler Curl_handler_imap_proxy = {
"IMAP", /* scheme */
- ZERO_NULL, /* setup_connection */
+ Curl_http_setup_conn, /* setup_connection */
Curl_http, /* do_it */
Curl_http_done, /* done */
ZERO_NULL, /* do_more */
@@ -188,7 +188,7 @@ static const struct Curl_handler Curl_handler_imap_proxy = {
static const struct Curl_handler Curl_handler_imaps_proxy = {
"IMAPS", /* scheme */
- ZERO_NULL, /* setup_connection */
+ Curl_http_setup_conn, /* setup_connection */
Curl_http, /* do_it */
Curl_http_done, /* done */
ZERO_NULL, /* do_more */
@@ -1669,13 +1669,11 @@ static CURLcode imap_init(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
- struct IMAP *imap = data->state.proto.imap;
+ struct IMAP *imap;
- if(!imap) {
- imap = data->state.proto.imap = calloc(sizeof(struct IMAP), 1);
- if(!imap)
- result = CURLE_OUT_OF_MEMORY;
- }
+ imap = data->state.proto.imap = calloc(sizeof(struct IMAP), 1);
+ if(!imap)
+ result = CURLE_OUT_OF_MEMORY;
return result;
}
@@ -1705,15 +1703,6 @@ static CURLcode imap_connect(struct connectdata *conn, bool *done)
*done = FALSE; /* default to not done yet */
- /* If there already is a protocol-specific struct allocated for this
- sessionhandle, deal with it */
- Curl_reset_reqproto(conn);
-
- /* Initialise the IMAP layer */
- result = imap_init(conn);
- if(result)
- return result;
-
/* We always support persistent connections in IMAP */
conn->bits.close = FALSE;
@@ -1891,15 +1880,6 @@ static CURLcode imap_do(struct connectdata *conn, bool *done)
*done = FALSE; /* default to false */
- /* Since connections can be re-used between SessionHandles, there might be a
- connection already existing but on a fresh SessionHandle struct. As such
- we make sure we have a good IMAP struct to play with. For new connections
- the IMAP struct is allocated and setup in the imap_connect() function. */
- Curl_reset_reqproto(conn);
- result = imap_init(conn);
- if(result)
- return result;
-
/* Parse the URL path */
result = imap_parse_url_path(conn);
if(result)
@@ -2018,6 +1998,11 @@ static CURLcode imap_setup_connection(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
+ /* Initialise the IMAP layer */
+ CURLcode result = imap_init(conn);
+ if(result)
+ return result;
+
if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
/* Unless we have asked to tunnel IMAP operations through the proxy, we
switch and use HTTP operations only */
@@ -2033,10 +2018,8 @@ static CURLcode imap_setup_connection(struct connectdata *conn)
#endif
}
- /* We explicitly mark this connection as persistent here as we're doing
- IMAP over HTTP and thus we accidentally avoid setting this value
- otherwise */
- conn->bits.close = FALSE;
+ /* set it up as an HTTP connection instead */
+ return conn->handler->setup_connection(conn);
#else
failf(data, "IMAP over http proxy requires HTTP support built-in!");
return CURLE_UNSUPPORTED_PROTOCOL;