mirror of
https://github.com/curl/curl.git
synced 2026-08-25 03:43:31 +03:00
mime: remove support "-" stdin pseudo-file name in curl_mime_filedata().
This feature is badly supported in Windows: as a replacement, a caller has to use curl_mime_data_cb() with fread, fseek and possibly fclose callbacks to process opened files. The cli tool and documentation are updated accordingly. The feature is however kept internally for form API compatibility, with the known caveats it always had. As a side effect, stdin size is not determined by the cli tool even if possible and this results in a chunked transfer encoding. Test 173 is updated accordingly.
This commit is contained in:
parent
045b076ae8
commit
1a3f4c1991
7 changed files with 48 additions and 14 deletions
|
|
@ -897,7 +897,10 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
|
|||
clen = -1;
|
||||
|
||||
if(post->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE)) {
|
||||
result = curl_mime_filedata(part, file->contents);
|
||||
if(!strcmp(file->contents, "-"))
|
||||
result = Curl_mime_file(part, stdin, 0);
|
||||
else
|
||||
result = curl_mime_filedata(part, file->contents);
|
||||
if(!result && (post->flags & HTTPPOST_READFILE))
|
||||
result = curl_mime_filename(part, NULL);
|
||||
}
|
||||
|
|
|
|||
15
lib/mime.c
15
lib/mime.c
|
|
@ -634,8 +634,18 @@ static int mime_part_rewind(struct Curl_mimepart *part)
|
|||
targetstate = MIMESTATE_BODY;
|
||||
if(part->state.state > targetstate) {
|
||||
res = CURL_SEEKFUNC_CANTSEEK;
|
||||
if(part->seekfunc)
|
||||
if(part->seekfunc) {
|
||||
res = part->seekfunc(part->arg, part->origin, SEEK_SET);
|
||||
switch(res) {
|
||||
case CURL_SEEKFUNC_OK:
|
||||
case CURL_SEEKFUNC_FAIL:
|
||||
case CURL_SEEKFUNC_CANTSEEK:
|
||||
break;
|
||||
default:
|
||||
res = CURL_SEEKFUNC_FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(res == CURL_SEEKFUNC_OK)
|
||||
|
|
@ -907,9 +917,6 @@ CURLcode curl_mime_filedata(struct Curl_mimepart *part, const char *filename)
|
|||
if(!part || !filename)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
|
||||
if(!strcmp(filename, "-"))
|
||||
return Curl_mime_file(part, stdin, 0);
|
||||
|
||||
if(stat(filename, &sbuf) || access(filename, R_OK))
|
||||
result = CURLE_READ_ERROR;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue