1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

imap: Added processing of the final FETCH responses

Not processing the final FETCH responses was not optimal, not only
because the response code would be ignored but it would also leave data
unread on the socket which would prohibit connection reuse.
This commit is contained in:
Jiri Hruska 2013-02-28 19:42:42 +01:00 committed by Steve Holme
parent 974c663471
commit cdea86ff67

View File

@ -1337,6 +1337,26 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
return result;
}
/* For the final response to the FETCH command */
static CURLcode imap_state_fetch_final_resp(struct connectdata *conn,
int imapcode,
imapstate instate)
{
CURLcode result = CURLE_OK;
(void)instate; /* No use for this yet */
if('O' != imapcode)
result = CURLE_FTP_WEIRD_SERVER_REPLY; /* TODO: Fix error code */
else
result = CURLE_OK;
/* End of do phase */
state(conn, IMAP_STOP);
return result;
}
static CURLcode imap_statemach_act(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
@ -1435,6 +1455,10 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
result = imap_state_fetch_resp(conn, imapcode, imapc->state);
break;
case IMAP_FETCH_FINAL:
result = imap_state_fetch_final_resp(conn, imapcode, imapc->state);
break;
case IMAP_LOGOUT:
/* fallthrough, just stop! */
default:
@ -1578,6 +1602,18 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
conn->bits.close = TRUE; /* marked for closure */
result = status; /* use the already set error code */
}
else if(!data->set.connect_only) {
state(conn, IMAP_FETCH_FINAL);
/* Run the state-machine
TODO: when the multi interface is used, this _really_ should be using
the imap_multi_statemach function but we have no general support for
non-blocking DONE operations, not in the multi state machine and with
Curl_done() invokes on several places in the code!
*/
result = imap_block_statemach(conn);
}
/* Cleanup our per-request based variables */
Curl_safefree(imap->mailbox);