mirror of
https://github.com/curl/curl.git
synced 2026-08-26 09:43:32 +03:00
mime: add client reader
Add `mime` client reader. Encapsulates reading from mime parts, getting their length, rewinding and unpausing. - remove special mime handling from sendf.c and easy.c - add general "unpause" method to client readers - use new reader in http/imap/smtp - make some mime functions static that are now only used internally In addition: - remove flag 'forbidchunk' as no longer needed Closes #13039
This commit is contained in:
parent
6c632b216b
commit
0ba47146f7
12 changed files with 370 additions and 129 deletions
17
lib/sendf.h
17
lib/sendf.h
|
|
@ -187,6 +187,7 @@ void Curl_cwriter_def_close(struct Curl_easy *data,
|
|||
struct Curl_cwriter *writer);
|
||||
|
||||
|
||||
|
||||
/* Client Reader Type, provides the implementation */
|
||||
struct Curl_crtype {
|
||||
const char *name; /* writer name. */
|
||||
|
|
@ -200,6 +201,7 @@ struct Curl_crtype {
|
|||
CURLcode (*resume_from)(struct Curl_easy *data,
|
||||
struct Curl_creader *reader, curl_off_t offset);
|
||||
CURLcode (*rewind)(struct Curl_easy *data, struct Curl_creader *reader);
|
||||
CURLcode (*unpause)(struct Curl_easy *data, struct Curl_creader *reader);
|
||||
size_t creader_size; /* sizeof() allocated struct Curl_creader */
|
||||
};
|
||||
|
||||
|
|
@ -236,6 +238,8 @@ CURLcode Curl_creader_def_resume_from(struct Curl_easy *data,
|
|||
curl_off_t offset);
|
||||
CURLcode Curl_creader_def_rewind(struct Curl_easy *data,
|
||||
struct Curl_creader *reader);
|
||||
CURLcode Curl_creader_def_unpause(struct Curl_easy *data,
|
||||
struct Curl_creader *reader);
|
||||
|
||||
/**
|
||||
* Convenience method for calling `reader->do_read()` that
|
||||
|
|
@ -268,6 +272,14 @@ void Curl_creader_free(struct Curl_easy *data, struct Curl_creader *reader);
|
|||
CURLcode Curl_creader_add(struct Curl_easy *data,
|
||||
struct Curl_creader *reader);
|
||||
|
||||
/**
|
||||
* Set the given reader, which needs to be of type CURL_CR_CLIENT,
|
||||
* as the new first reader. Discard any installed readers and init
|
||||
* the reader chain anew.
|
||||
* The function takes ownership of `r`.
|
||||
*/
|
||||
CURLcode Curl_creader_set(struct Curl_easy *data, struct Curl_creader *r);
|
||||
|
||||
/**
|
||||
* Read at most `blen` bytes at `buf` from the client.
|
||||
* @param date the transfer to read client bytes for
|
||||
|
|
@ -328,6 +340,11 @@ curl_off_t Curl_creader_client_length(struct Curl_easy *data);
|
|||
*/
|
||||
CURLcode Curl_creader_resume_from(struct Curl_easy *data, curl_off_t offset);
|
||||
|
||||
/**
|
||||
* Unpause all installed readers.
|
||||
*/
|
||||
CURLcode Curl_creader_unpause(struct Curl_easy *data);
|
||||
|
||||
/**
|
||||
* Set the client reader to provide 0 bytes, immediate EOS.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue