w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 3eab48ca780d0cfb253c519288878ec91753a336
parent 42eebe032219d99eb534507bf546c9dec7e19549
Author: ukai <ukai>
Date:   Sat,  8 Feb 2003 18:23:52 +0000

[w3m-dev 03737] local-CGI POST
* local.c (localcgi_post): use tmp file
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 5+++++
Mlocal.c | 25+++++++++++++++----------
2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -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> * [w3m-dev 03736] dirlist sort diff --git a/local.c b/local.c @@ -344,26 +344,27 @@ localcgi_post(char *uri, char *qstr, FormList *request, char *referer) FILE *fr = NULL, *fw = NULL; int status; 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); if (check_local_cgi(file, status) < 0) return NULL; writeLocalCookie(); - if (request && request->enctype != FORM_ENCTYPE_MULTIPART) - pid = open_pipe_rw(&fr, &fw); - else - pid = open_pipe_rw(&fr, NULL); + if (request && request->enctype != FORM_ENCTYPE_MULTIPART) { + tmpf = tmpfname(TMPF_DFL, NULL)->ptr; + fw = fopen(tmpf, "w"); + if (!fw) + return NULL; + } + pid = open_pipe_rw(&fr, NULL); if (pid < 0) return NULL; else if (pid) { - if (fw) { - fwrite(request->body, sizeof(char), request->length, fw); + if (fw) fclose(fw); - } return fr; } - setup_child(TRUE, 2, -1); + setup_child(TRUE, 2, fw ? fileno(fw) : -1); if (qstr) 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); freopen(request->body, "r", stdin); } - else + else { set_environ("CONTENT_TYPE", "application/x-www-form-urlencoded"); + fwrite(request->body, sizeof(char), request->length, fw); + fclose(fw); + freopen(tmpf, "r", stdin); + } } else { set_environ("REQUEST_METHOD", "GET");