Beispiel #1
0
static int modifyHeader2WithReply(int fd, HttpReply *reply)
{	
	Array * modparam = cc_get_mod_param_array(fd, mod);
	int paramcount = cc_get_mod_param_count(fd, mod);
	assert(modparam);
	struct mod_conf_param *param = NULL;
	int count = 0; 
	int loop = 0;
	int ret = 0;
	int i = 0;
	for(i=0; i<paramcount; i++){
		assert(modparam->items[i]);
		param = (struct mod_conf_param *)((cc_mod_param*)modparam->items[i])->param;
		assert(param);
		count = param->count;
		ret =0;
		for(loop=0; loop<count; loop++)
		{
			if(2 == param->acp[loop]->direct)
			{
				ret = modifyHeader2(param->acp[loop], reply);
				//must clean it when we wanna to update HttpReply struct
				ret++;
			}
		}
	}	
	httpReplyHdrCacheClean(reply);	
	httpReplyHdrCacheInit(reply);
	return 0;
}
Beispiel #2
0
static void
httpReplyInit(HttpReply * rep)
{
    assert(rep);
    rep->hdr_sz = 0;
    rep->pstate = psReadyToParseStartLine;
    httpBodyInit(&rep->body);
    httpHeaderInit(&rep->header, hoReply);
    httpReplyHdrCacheInit(rep);
    httpStatusLineInit(&rep->sline);
}
Beispiel #3
0
void
httpReplyUpdateOnNotModified(HttpReply * rep, HttpReply * freshRep)
{
    assert(rep && freshRep);
    /* clean cache */
    httpReplyHdrCacheClean(rep);
    /* update raw headers */
    httpHeaderUpdate(&rep->header, &freshRep->header,
	(const HttpHeaderMask *) &Denied304HeadersMask);
    /* init cache */
    httpReplyHdrCacheInit(rep);
}
Beispiel #4
0
/*
 * parses a 0-terminating buffer into HttpReply. 
 * Returns:
 *      +1 -- success 
 *       0 -- need more data (partial parse)
 *      -1 -- parse error
 */
static int
httpReplyParseStep(HttpReply * rep, const char *buf, int atEnd)
{
    const char *parse_start = buf;
    const char *blk_start, *blk_end;
    const char **parse_end_ptr = &blk_end;
    assert(rep);
    assert(parse_start);
    assert(rep->pstate < psParsed);

    *parse_end_ptr = parse_start;
    if (rep->pstate == psReadyToParseStartLine) {
	if (!httpReplyIsolateStart(&parse_start, &blk_start, &blk_end))
	    return 0;
	if (!httpStatusLineParse(&rep->sline, blk_start, blk_end))
	    return httpReplyParseError(rep);

	*parse_end_ptr = parse_start;
	rep->hdr_sz = *parse_end_ptr - buf;
	rep->pstate++;
    }
    if (rep->pstate == psReadyToParseHeaders) {
	if (!httpMsgIsolateHeaders(&parse_start, &blk_start, &blk_end)) {
	    if (atEnd)
		blk_start = parse_start, blk_end = blk_start + strlen(blk_start);
	    else
		return 0;
	}
	if (!httpHeaderParse(&rep->header, blk_start, blk_end))
	    return httpReplyParseError(rep);

	httpReplyHdrCacheInit(rep);

	*parse_end_ptr = parse_start;
	rep->hdr_sz = *parse_end_ptr - buf;
	rep->pstate++;
    }
    return 1;
}