Torsten Foertsch's improvements
This commit is contained in:
parent
0cb4814105
commit
5b7a5046e6
@ -76,6 +76,7 @@ struct HttpPost {
|
|||||||
link should link to following files */
|
link should link to following files */
|
||||||
long flags; /* as defined below */
|
long flags; /* as defined below */
|
||||||
#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */
|
#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */
|
||||||
|
#define HTTPPOST_READFILE (1<<1) /* specified content is a file name */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*curl_progress_callback)(void *clientp,
|
typedef int (*curl_progress_callback)(void *clientp,
|
||||||
|
@ -119,7 +119,7 @@ int FormParse(char *input,
|
|||||||
/* nextarg MUST be a string in the format 'name=contents' and we'll
|
/* nextarg MUST be a string in the format 'name=contents' and we'll
|
||||||
build a linked list with the info */
|
build a linked list with the info */
|
||||||
char name[256];
|
char name[256];
|
||||||
char contents[1024]="";
|
char contents[4096]="";
|
||||||
char major[128];
|
char major[128];
|
||||||
char minor[128];
|
char minor[128];
|
||||||
long flags = 0;
|
long flags = 0;
|
||||||
@ -132,7 +132,7 @@ int FormParse(char *input,
|
|||||||
struct HttpPost *subpost; /* a sub-node */
|
struct HttpPost *subpost; /* a sub-node */
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if(1 <= sscanf(input, "%255[^ =] = %1023[^\n]", name, contents)) {
|
if(1 <= sscanf(input, "%255[^ =] = %4095[^\n]", name, contents)) {
|
||||||
/* the input was using the correct format */
|
/* the input was using the correct format */
|
||||||
contp = contents;
|
contp = contents;
|
||||||
|
|
||||||
@ -281,8 +281,14 @@ int FormParse(char *input,
|
|||||||
if(post) {
|
if(post) {
|
||||||
memset(post, 0, sizeof(struct HttpPost));
|
memset(post, 0, sizeof(struct HttpPost));
|
||||||
GetStr(&post->name, name); /* get the name */
|
GetStr(&post->name, name); /* get the name */
|
||||||
GetStr(&post->contents, contp); /* get the contents */
|
if( contp[0]=='<' ) {
|
||||||
post->flags = 0;
|
GetStr(&post->contents, contp+1); /* get the contents */
|
||||||
|
post->flags = HTTPPOST_READFILE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GetStr(&post->contents, contp); /* get the contents */
|
||||||
|
post->flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* make the previous point to this */
|
/* make the previous point to this */
|
||||||
if(*last_post)
|
if(*last_post)
|
||||||
@ -334,7 +340,7 @@ static int AddFormData(struct FormData **formp,
|
|||||||
static int AddFormDataf(struct FormData **formp,
|
static int AddFormDataf(struct FormData **formp,
|
||||||
char *fmt, ...)
|
char *fmt, ...)
|
||||||
{
|
{
|
||||||
char s[1024];
|
char s[4096];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsprintf(s, fmt, ap);
|
vsprintf(s, fmt, ap);
|
||||||
@ -454,15 +460,14 @@ struct FormData *getFormData(struct HttpPost *post,
|
|||||||
if(file->contenttype &&
|
if(file->contenttype &&
|
||||||
!strnequal("text/", file->contenttype, 5)) {
|
!strnequal("text/", file->contenttype, 5)) {
|
||||||
/* this is not a text content, mention our binary encoding */
|
/* this is not a text content, mention our binary encoding */
|
||||||
size += AddFormDataf(&form,
|
size += AddFormData(&form, "\r\nContent-Transfer-Encoding: binary", 0);
|
||||||
"\r\nContent-Transfer-Encoding: binary");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size += AddFormDataf(&form,
|
size += AddFormData(&form, "\r\n\r\n", 0);
|
||||||
"\r\n\r\n");
|
|
||||||
|
|
||||||
if(post->flags & HTTPPOST_FILENAME) {
|
if((post->flags & HTTPPOST_FILENAME) ||
|
||||||
|
(post->flags & HTTPPOST_READFILE)) {
|
||||||
/* we should include the contents from the specified file */
|
/* we should include the contents from the specified file */
|
||||||
FILE *fileread;
|
FILE *fileread;
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
@ -479,15 +484,12 @@ struct FormData *getFormData(struct HttpPost *post,
|
|||||||
}
|
}
|
||||||
if(fileread != stdin)
|
if(fileread != stdin)
|
||||||
fclose(fileread);
|
fclose(fileread);
|
||||||
|
} else {
|
||||||
|
size += AddFormData(&form, "[File wasn't found by client]", 0);
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
size += AddFormDataf(&form, "[File wasn't found by client]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* include the contents we got */
|
/* include the contents we got */
|
||||||
size += AddFormDataf(&form,
|
size += AddFormData(&form, post->contents, 0);
|
||||||
post->contents);
|
|
||||||
}
|
}
|
||||||
} while((file = file->more)); /* for each specified file for this field */
|
} while((file = file->more)); /* for each specified file for this field */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user