summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/server_fcgi.c
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2014-08-06 15:08:05 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2014-08-06 15:08:05 +0000
commitb6f7f6be6ba1f8570e030a7bb30720dc1fd8e01e (patch)
treee016b57daf11818e67ed90aeee35b1abc02a56b9 /usr.sbin/httpd/server_fcgi.c
parenta127b08b4a9ad4146c260233fd2103e03720ed4f (diff)
http POST support
with & OK reyk@
Diffstat (limited to 'usr.sbin/httpd/server_fcgi.c')
-rw-r--r--usr.sbin/httpd/server_fcgi.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c
index d1c93552e5f..f2d14f4598f 100644
--- a/usr.sbin/httpd/server_fcgi.c
+++ b/usr.sbin/httpd/server_fcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_fcgi.c,v 1.22 2014/08/06 13:40:18 florian Exp $ */
+/* $OpenBSD: server_fcgi.c,v 1.23 2014/08/06 15:08:04 florian Exp $ */
/*
* Copyright (c) 2014 Florian Obser <florian@openbsd.org>
@@ -45,7 +45,6 @@
#include "httpd.h"
#include "http.h"
-#define FCGI_CONTENT_SIZE 65535
#define FCGI_PADDING_SIZE 255
#define FCGI_RECORD_SIZE \
(sizeof(struct fcgi_record_header) + FCGI_CONTENT_SIZE + FCGI_PADDING_SIZE)
@@ -326,15 +325,16 @@ server_fcgi(struct httpd *env, struct client *clt)
bufferevent_write(clt->clt_srvbev, &param.buf,
sizeof(struct fcgi_record_header));
- h->type = FCGI_STDIN;
-
- bufferevent_write(clt->clt_srvbev, &param.buf,
- sizeof(struct fcgi_record_header));
-
bufferevent_settimeout(clt->clt_srvbev,
srv_conf->timeout.tv_sec, srv_conf->timeout.tv_sec);
bufferevent_enable(clt->clt_srvbev, EV_READ|EV_WRITE);
- bufferevent_disable(clt->clt_bev, EV_READ);
+ if (clt->clt_toread != 0) {
+ server_read_httpcontent(clt->clt_bev, clt);
+ bufferevent_enable(clt->clt_bev, EV_READ);
+ } else {
+ bufferevent_disable(clt->clt_bev, EV_READ);
+ fcgi_add_stdin(clt, NULL);
+ }
/*
* persist is not supported yet because we don't get the
@@ -354,6 +354,30 @@ server_fcgi(struct httpd *env, struct client *clt)
}
int
+fcgi_add_stdin(struct client *clt, struct evbuffer *evbuf)
+{
+ struct fcgi_record_header h;
+
+ h.version = 1;
+ h.type = FCGI_STDIN;
+ h.id = htons(1);
+ h.padding_len = 0;
+
+ if (evbuf == NULL) {
+ h.content_len = 0;
+ return bufferevent_write(clt->clt_srvbev, &h,
+ sizeof(struct fcgi_record_header));
+ } else {
+ h.content_len = htons(EVBUFFER_LENGTH(evbuf));
+ if (bufferevent_write(clt->clt_srvbev, &h,
+ sizeof(struct fcgi_record_header)) == -1)
+ return -1;
+ return bufferevent_write_buffer(clt->clt_srvbev, evbuf);
+ }
+ return (0);
+}
+
+int
fcgi_add_param(struct server_fcgi_param *p, const char *key,
const char *val, struct client *clt)
{