[w3m-dev 03737] local-CGI POST

* local.c (localcgi_post): use tmp file
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2003-02-08 18:23:52 +00:00
parent c71b4fd2e8
commit d779a33d23
2 changed files with 22 additions and 12 deletions

View File

@@ -1,3 +1,8 @@
2003-02-09 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03737] local-CGI POST
* local.c (localcgi_post): use tmp file
2003-02-08 Hiroyuki Ito <hito@crl.go.jp> 2003-02-08 Hiroyuki Ito <hito@crl.go.jp>
* [w3m-dev 03736] dirlist sort * [w3m-dev 03736] dirlist sort
@@ -7123,4 +7128,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.743 2003/02/07 15:06:15 ukai Exp $ $Id: ChangeLog,v 1.744 2003/02/08 18:23:52 ukai Exp $

27
local.c
View File

@@ -1,4 +1,4 @@
/* $Id: local.c,v 1.27 2003/01/31 16:26:41 ukai Exp $ */ /* $Id: local.c,v 1.28 2003/02/08 18:23:53 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@@ -344,26 +344,27 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
FILE *fr = NULL, *fw = NULL; FILE *fr = NULL, *fw = NULL;
int status; int status;
pid_t pid; pid_t pid;
char *file = uri, *name = uri, *path_info = NULL; char *file = uri, *name = uri, *path_info = NULL, *tmpf = NULL;
status = cgi_filename(uri, &file, &name, &path_info); status = cgi_filename(uri, &file, &name, &path_info);
if (check_local_cgi(file, status) < 0) if (check_local_cgi(file, status) < 0)
return NULL; return NULL;
writeLocalCookie(); writeLocalCookie();
if (request && request->enctype != FORM_ENCTYPE_MULTIPART) if (request && request->enctype != FORM_ENCTYPE_MULTIPART) {
pid = open_pipe_rw(&fr, &fw); tmpf = tmpfname(TMPF_DFL, NULL)->ptr;
else fw = fopen(tmpf, "w");
pid = open_pipe_rw(&fr, NULL); if (!fw)
return NULL;
}
pid = open_pipe_rw(&fr, NULL);
if (pid < 0) if (pid < 0)
return NULL; return NULL;
else if (pid) { else if (pid) {
if (fw) { if (fw)
fwrite(request->body, sizeof(char), request->length, fw);
fclose(fw); fclose(fw);
}
return fr; return fr;
} }
setup_child(TRUE, 2, -1); setup_child(TRUE, 2, fw ? fileno(fw) : -1);
if (qstr) if (qstr)
uri = Strnew_m_charp(uri, "?", qstr, NULL)->ptr; uri = Strnew_m_charp(uri, "?", qstr, NULL)->ptr;
@@ -383,8 +384,12 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer)
request->boundary)->ptr); request->boundary)->ptr);
freopen(request->body, "r", stdin); freopen(request->body, "r", stdin);
} }
else else {
set_environ("CONTENT_TYPE", "application/x-www-form-urlencoded"); set_environ("CONTENT_TYPE", "application/x-www-form-urlencoded");
fwrite(request->body, sizeof(char), request->length, fw);
fclose(fw);
freopen(tmpf, "r", stdin);
}
} }
else { else {
set_environ("REQUEST_METHOD", "GET"); set_environ("REQUEST_METHOD", "GET");