Browse Source

[multiple] modules read reqbody via fn ptr

r->con->reqbody_read() replaces connection_handle_read_post_state()

future: might provide different callbacks for request body with
Content-Length versus request body sent via Transfer-Encoding: chunked
master
Glenn Strauss 1 year ago
parent
commit
8940fec894
  1. 1
      src/base.h
  2. 1
      src/connections.c
  3. 2
      src/gw_backend.c
  4. 2
      src/mod_cgi.c
  5. 9
      src/mod_webdav.c

1
src/base.h

@ -45,6 +45,7 @@ struct connection {
int (* network_write)(struct connection *con, chunkqueue *cq, off_t max_bytes);
int (* network_read)(struct connection *con, chunkqueue *cq, off_t max_bytes);
handler_t (* reqbody_read)(struct request_st *r);
server *srv;
void *plugin_slots;

1
src/connections.c

@ -1048,6 +1048,7 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
con->fdn = fdevent_register(srv->ev, con->fd, connection_handle_fdevent, con);
con->network_read = connection_read_cq;
con->network_write = connection_write_cq;
con->reqbody_read = connection_handle_read_post_state;
request_st * const r = &con->request;
connection_set_state(r, CON_STATE_REQUEST_START);

2
src/gw_backend.c

@ -2063,7 +2063,7 @@ handler_t gw_handle_subrequest(request_st * const r, void *p_d) {
if (0 != hctx->wb->bytes_in) return HANDLER_WAIT_FOR_EVENT;
}
else {
handler_t rc = connection_handle_read_post_state(r);
handler_t rc = r->con->reqbody_read(r);
/* XXX: create configurable flag */
/* CGI environment requires that Content-Length be set.

2
src/mod_cgi.c

@ -967,7 +967,7 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
r->conf.stream_request_body &= ~FDEVENT_STREAM_REQUEST_POLLIN;
if (-1 != hctx->fd) return HANDLER_WAIT_FOR_EVENT;
} else {
handler_t rc = connection_handle_read_post_state(r);
handler_t rc = r->con->reqbody_read(r);
if (!chunkqueue_is_empty(cq)) {
if (fdevent_fdnode_interest(hctx->fdntocgi) & FDEVENT_OUT) {
return (rc == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : rc;

9
src/mod_webdav.c

@ -211,7 +211,6 @@
#include "http_header.h"
#include "etag.h"
#include "log.h"
#include "connections.h"/* connection_handle_read_post_state() */
#include "request.h"
#include "response.h" /* http_response_redirect_to_directory() */
#include "stat_cache.h" /* stat_cache_mimetype_by_ext() */
@ -3809,7 +3808,7 @@ mod_webdav_propfind (request_st * const r, const plugin_config * const pconf)
if (r->reqbody_length) {
#ifdef USE_PROPPATCH
if (r->state == CON_STATE_READ_POST) {
handler_t rc = connection_handle_read_post_state(r);
handler_t rc = r->con->reqbody_read(r);
if (rc != HANDLER_GO_ON) return rc;
}
#else
@ -4530,7 +4529,7 @@ mod_webdav_put (request_st * const r, const plugin_config * const pconf)
{
if (r->state == CON_STATE_READ_POST) {
int first_read = chunkqueue_is_empty(r->reqbody_queue);
handler_t rc = connection_handle_read_post_state(r);
handler_t rc = r->con->reqbody_read(r);
if (rc != HANDLER_GO_ON) {
if (first_read && rc == HANDLER_WAIT_FOR_EVENT
&& 0 != webdav_if_match_or_unmodified_since(r, NULL)) {
@ -5068,7 +5067,7 @@ mod_webdav_proppatch (request_st * const r, const plugin_config * const pconf)
}
if (r->state == CON_STATE_READ_POST) {
handler_t rc = connection_handle_read_post_state(r);
handler_t rc = r->con->reqbody_read(r);
if (rc != HANDLER_GO_ON) return rc;
}
@ -5284,7 +5283,7 @@ mod_webdav_lock (request_st * const r, const plugin_config * const pconf)
if (r->reqbody_length) {
if (r->state == CON_STATE_READ_POST) {
handler_t rc = connection_handle_read_post_state(r);
handler_t rc = r->con->reqbody_read(r);
if (rc != HANDLER_GO_ON) return rc;
}
}

Loading…
Cancel
Save