mirror of
https://github.com/curl/curl.git
synced 2025-09-12 07:02:41 +03:00
pop3: use the protocol handler ->write_resp
Remove the "hardcoded" logic for the pop3 transfer handler and instead use the generic protocol handler write_resp function. Remove the check for 'data->req.ignorebody' because I cannot find a code flow where this is set for POP3. Closes #14684
This commit is contained in:
parent
10873ec5a9
commit
89b9fb64a5
19
lib/pop3.c
19
lib/pop3.c
|
@ -107,6 +107,11 @@ static CURLcode pop3_continue_auth(struct Curl_easy *data, const char *mech,
|
||||||
static CURLcode pop3_cancel_auth(struct Curl_easy *data, const char *mech);
|
static CURLcode pop3_cancel_auth(struct Curl_easy *data, const char *mech);
|
||||||
static CURLcode pop3_get_message(struct Curl_easy *data, struct bufref *out);
|
static CURLcode pop3_get_message(struct Curl_easy *data, struct bufref *out);
|
||||||
|
|
||||||
|
/* This function scans the body after the end-of-body and writes everything
|
||||||
|
* until the end is found */
|
||||||
|
static CURLcode pop3_write(struct Curl_easy *data,
|
||||||
|
const char *str, size_t nread, bool is_eos);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* POP3 protocol handler.
|
* POP3 protocol handler.
|
||||||
*/
|
*/
|
||||||
|
@ -125,7 +130,7 @@ const struct Curl_handler Curl_handler_pop3 = {
|
||||||
ZERO_NULL, /* domore_getsock */
|
ZERO_NULL, /* domore_getsock */
|
||||||
ZERO_NULL, /* perform_getsock */
|
ZERO_NULL, /* perform_getsock */
|
||||||
pop3_disconnect, /* disconnect */
|
pop3_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* write_resp */
|
pop3_write, /* write_resp */
|
||||||
ZERO_NULL, /* write_resp_hd */
|
ZERO_NULL, /* write_resp_hd */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
ZERO_NULL, /* attach connection */
|
ZERO_NULL, /* attach connection */
|
||||||
|
@ -155,7 +160,7 @@ const struct Curl_handler Curl_handler_pop3s = {
|
||||||
ZERO_NULL, /* domore_getsock */
|
ZERO_NULL, /* domore_getsock */
|
||||||
ZERO_NULL, /* perform_getsock */
|
ZERO_NULL, /* perform_getsock */
|
||||||
pop3_disconnect, /* disconnect */
|
pop3_disconnect, /* disconnect */
|
||||||
ZERO_NULL, /* write_resp */
|
pop3_write, /* write_resp */
|
||||||
ZERO_NULL, /* write_resp_hd */
|
ZERO_NULL, /* write_resp_hd */
|
||||||
ZERO_NULL, /* connection_check */
|
ZERO_NULL, /* connection_check */
|
||||||
ZERO_NULL, /* attach connection */
|
ZERO_NULL, /* attach connection */
|
||||||
|
@ -948,8 +953,8 @@ static CURLcode pop3_state_command_resp(struct Curl_easy *data,
|
||||||
pp->nfinal = 0; /* done */
|
pp->nfinal = 0; /* done */
|
||||||
|
|
||||||
if(!data->req.no_body) {
|
if(!data->req.no_body) {
|
||||||
result = Curl_pop3_write(data, Curl_dyn_ptr(&pp->recvbuf),
|
result = pop3_write(data, Curl_dyn_ptr(&pp->recvbuf),
|
||||||
Curl_dyn_len(&pp->recvbuf));
|
Curl_dyn_len(&pp->recvbuf), FALSE);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1447,12 +1452,13 @@ static CURLcode pop3_parse_custom_request(struct Curl_easy *data)
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
*
|
*
|
||||||
* Curl_pop3_write()
|
* pop3_write()
|
||||||
*
|
*
|
||||||
* This function scans the body after the end-of-body and writes everything
|
* This function scans the body after the end-of-body and writes everything
|
||||||
* until the end is found.
|
* until the end is found.
|
||||||
*/
|
*/
|
||||||
CURLcode Curl_pop3_write(struct Curl_easy *data, const char *str, size_t nread)
|
static CURLcode pop3_write(struct Curl_easy *data, const char *str,
|
||||||
|
size_t nread, bool is_eos)
|
||||||
{
|
{
|
||||||
/* This code could be made into a special function in the handler struct */
|
/* This code could be made into a special function in the handler struct */
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
@ -1462,6 +1468,7 @@ CURLcode Curl_pop3_write(struct Curl_easy *data, const char *str, size_t nread)
|
||||||
bool strip_dot = FALSE;
|
bool strip_dot = FALSE;
|
||||||
size_t last = 0;
|
size_t last = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
(void)is_eos;
|
||||||
|
|
||||||
/* Search through the buffer looking for the end-of-body marker which is
|
/* Search through the buffer looking for the end-of-body marker which is
|
||||||
5 bytes (0d 0a 2e 0d 0a). Note that a line starting with a dot matches
|
5 bytes (0d 0a 2e 0d 0a). Note that a line starting with a dot matches
|
||||||
|
|
|
@ -90,9 +90,4 @@ extern const struct Curl_handler Curl_handler_pop3s;
|
||||||
#define POP3_EOB "\x0d\x0a\x2e\x0d\x0a"
|
#define POP3_EOB "\x0d\x0a\x2e\x0d\x0a"
|
||||||
#define POP3_EOB_LEN 5
|
#define POP3_EOB_LEN 5
|
||||||
|
|
||||||
/* This function scans the body after the end-of-body and writes everything
|
|
||||||
* until the end is found */
|
|
||||||
CURLcode Curl_pop3_write(struct Curl_easy *data,
|
|
||||||
const char *str, size_t nread);
|
|
||||||
|
|
||||||
#endif /* HEADER_CURL_POP3_H */
|
#endif /* HEADER_CURL_POP3_H */
|
||||||
|
|
|
@ -1186,15 +1186,7 @@ CURLcode Curl_xfer_write_resp(struct Curl_easy *data,
|
||||||
int cwtype = CLIENTWRITE_BODY;
|
int cwtype = CLIENTWRITE_BODY;
|
||||||
if(is_eos)
|
if(is_eos)
|
||||||
cwtype |= CLIENTWRITE_EOS;
|
cwtype |= CLIENTWRITE_EOS;
|
||||||
|
result = Curl_client_write(data, cwtype, buf, blen);
|
||||||
#ifndef CURL_DISABLE_POP3
|
|
||||||
if(blen && data->conn->handler->protocol & PROTO_FAMILY_POP3) {
|
|
||||||
result = data->req.ignorebody? CURLE_OK :
|
|
||||||
Curl_pop3_write(data, buf, blen);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif /* CURL_DISABLE_POP3 */
|
|
||||||
result = Curl_client_write(data, cwtype, buf, blen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user