Esempio n. 1
0
vmod_cache_req_body(VRT_CTX, VCL_BYTES size)
{
	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
	if (size < 0)
		size = 0;
	if (VRT_CacheReqBody(ctx, (size_t)size) < 0)
		return (0);
	return (1);
}
Esempio n. 2
0
File: vmod_vsf.c Progetto: aaam/VSF
vmod_body(VRT_CTX, struct vmod_priv *priv, VCL_BYTES maxsize)
{
	struct vsb *vsb;
	const char *p;
	ssize_t size;

	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);

	if (priv->priv)
		return (VSB_data(priv->priv));
	if (!http_GetHdr(ctx->req->http, H_Content_Type, &p))
		return (NULL);
	if (strncasecmp(p, FORM_URLENCODED, sizeof(FORM_URLENCODED) - 1)) {
		VSLb(ctx->vsl, SLT_Error,
		    "vsf.body: Unsupported form encoding (%s)", p);
		return (NULL);
	}
	size = VRT_CacheReqBody(ctx, maxsize);
	if (size <= 0)
		return (NULL);
	vsb = VSB_new(NULL, NULL, size + 1, 0);
	if (!vsb) {
		VSLb(ctx->vsl, SLT_Error, "vsf.body: Out of memory");
		return (NULL);
	}
	if (VRB_Iterate(ctx->req, vsf_iter_req_body, vsb) == -1) {
		VSLb(ctx->vsl, SLT_Error,
		    "vsf.body: Problem fetching the body");
		VSB_delete(vsb);
		return (NULL);
	}
	AZ(VSB_finish(vsb));
	priv->free = (vmod_priv_free_f *)VSB_delete;
	priv->priv = vsb;
	return (VSB_data(vsb));
}