Commit 3cc846ee authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Introduce "transports" which is how responses to requests gets

delivered.

Transports are a superset of protocols because internal requests,
notably ESI:includes, doesn't use a HTTP protocol to deliver their
response, but have have ødipal ways of doing things.
parent b5887874
......@@ -111,6 +111,7 @@ struct object;
struct objhead;
struct pool;
struct poolparam;
struct transport;
struct req;
struct sess;
struct suckaddr;
......@@ -541,6 +542,10 @@ struct req {
struct sess *sp;
struct worker *wrk;
struct pool_task task;
const struct transport *transport;
void *transport_priv;
enum req_step req_step;
VTAILQ_ENTRY(req) w_list;
......@@ -672,6 +677,21 @@ struct sess {
};
/*--------------------------------------------------------------------
* A transport is how we talk HTTP for a given request.
* This is different from a protocol because ESI child requests have
* their own "protocol" to talk to the parent ESI request, which may
* or may not, be talking a "real" HTTP protocol itself.
*/
typedef void vtr_deliver_f (struct req *);
struct transport {
unsigned magic;
#define TRANSPORT_MAGIC 0xf157f32f
vtr_deliver_f *deliver;
};
/* Prototypes etc ----------------------------------------------------*/
/* Cross file typedefs */
......
......@@ -80,7 +80,8 @@ cnt_vdp(struct req *req, struct busyobj *bo)
VRG_dorange(req, r);
}
V1D_Deliver(req);
CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC);
req->transport->deliver(req);
}
/*--------------------------------------------------------------------
......
......@@ -60,7 +60,7 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv,
/*--------------------------------------------------------------------
*/
void
void __match_proto__(vtr_deliver_f)
V1D_Deliver(struct req *req)
{
enum objiter_status ois;
......
......@@ -42,6 +42,11 @@
#include "vtcp.h"
static const struct transport http1_transport = {
.magic = TRANSPORT_MAGIC,
.deliver = V1D_Deliver,
};
/*----------------------------------------------------------------------
*/
......@@ -255,10 +260,12 @@ HTTP1_Session(struct worker *wrk, struct req *req)
sp->sess_step = S_STP_H1PROC;
break;
case S_STP_H1PROC:
req->transport = &http1_transport;
if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK) {
sp->sess_step = S_STP_H1BUSY;
return;
}
req->transport = NULL;
sp->sess_step = S_STP_H1CLEANUP;
break;
case S_STP_H1CLEANUP:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment