src/proto_http.c
int apply_filter_to_sts_line(struct session *t, struct channel *rtr, struct hdr_exp *exp)
{
	char term;
	char *cur_ptr, *cur_end;
	int done;
	struct http_txn *txn = &t->txn;
	int delta;


	if (unlikely(txn->flags & TX_SVDENY))
		return 1;
	else if (unlikely(txn->flags & TX_SVALLOW) &&
		 (exp->action == ACT_ALLOW ||
		  exp->action == ACT_DENY))
		return 0;
	else if (exp->action == ACT_REMOVE)
		return 0;

	done = 0;

	cur_ptr = rtr->buf->p;
	cur_end = cur_ptr + txn->rsp.sl.st.l;

	/* Now we have the status line between cur_ptr and cur_end */

	/* The annoying part is that pattern matching needs
	 * that we modify the contents to null-terminate all
	 * strings before testing them.
	 */

	term = *cur_end;
	*cur_end = '\0';

	if (regexec(exp->preg, cur_ptr, MAX_MATCH, pmatch, 0) == 0) {
		switch (exp->action) {
		case ACT_ALLOW:
			txn->flags |= TX_SVALLOW;
			done = 1;
			break;

		case ACT_DENY:
			txn->flags |= TX_SVDENY;
			done = 1;
			break;

		case ACT_REPLACE:
			*cur_end = term; /* restore the string terminator */
			trash.len = exp_replace(trash.str, cur_ptr, exp->replace, pmatch);
			delta = buffer_replace2(rtr->buf, cur_ptr, cur_end, trash.str, trash.len);
			/* FIXME: if the user adds a newline in the replacement, the
			 * index will not be recalculated for now, and the new line
			 * will not be counted as a new header.
			 */

			http_msg_move_end(&txn->rsp, delta);
			cur_end += delta;
			cur_end = (char *)http_parse_stsline(&txn->rsp,
							     HTTP_MSG_RPVER,
							     cur_ptr, cur_end + 1,
							     NULL, NULL);
			if (unlikely(!cur_end))
				return -1;

			/* we have a full respnse and we know that we have either a CR
			 * or an LF at <ptr>.
			 */
			txn->status = strl2ui(rtr->buf->p + txn->rsp.sl.st.c, txn->rsp.sl.st.c_l);
			hdr_idx_set_start(&txn->hdr_idx, txn->rsp.sl.st.l, *cur_end == '\r');
			/* there is no point trying this regex on headers */
			return 1;
		}
	}
	*cur_end = term; /* restore the string terminator */
	return done;
}
/* Apply the filter to the status line in the response buffer <rtr>.
 * Returns 0 if nothing has been done, 1 if the filter has been applied,
 * or -1 if a replacement resulted in an invalid status line.
 */
Apply the filter to the status line in the response buffer .
Returns 0 if nothing has been done, 1 if the filter has been applied,
or -1 if a replacement resulted in an invalid status line.
Apply the filter to the status line in the response buffer . Returns 0 if nothing has been done 1 if the filter has been applied or - 1 if a replacement resulted in an invalid status line .
int apply_filter_to_sts_line(struct session *t, struct channel *rtr, struct hdr_exp *exp)
{
	char term;
	char *cur_ptr, *cur_end;
	int done;
	struct http_txn *txn = &t->txn;
	int delta;
	if (unlikely(txn->flags & TX_SVDENY))
		return 1;
	else if (unlikely(txn->flags & TX_SVALLOW) &&
		 (exp->action == ACT_ALLOW ||
		  exp->action == ACT_DENY))
		return 0;
	else if (exp->action == ACT_REMOVE)
		return 0;
	done = 0;
	cur_ptr = rtr->buf->p;
	cur_end = cur_ptr + txn->rsp.sl.st.l;
	term = *cur_end;
	*cur_end = '\0';
	if (regexec(exp->preg, cur_ptr, MAX_MATCH, pmatch, 0) == 0) {
		switch (exp->action) {
		case ACT_ALLOW:
			txn->flags |= TX_SVALLOW;
			done = 1;
			break;
		case ACT_DENY:
			txn->flags |= TX_SVDENY;
			done = 1;
			break;
		case ACT_REPLACE:
			*cur_end = term; 
			trash.len = exp_replace(trash.str, cur_ptr, exp->replace, pmatch);
			delta = buffer_replace2(rtr->buf, cur_ptr, cur_end, trash.str, trash.len);
			http_msg_move_end(&txn->rsp, delta);
			cur_end += delta;
			cur_end = (char *)http_parse_stsline(&txn->rsp,
							     HTTP_MSG_RPVER,
							     cur_ptr, cur_end + 1,
							     NULL, NULL);
			if (unlikely(!cur_end))
				return -1;
			txn->status = strl2ui(rtr->buf->p + txn->rsp.sl.st.c, txn->rsp.sl.st.c_l);
			hdr_idx_set_start(&txn->hdr_idx, txn->rsp.sl.st.l, *cur_end == '\r');
			return 1;
		}
	}
	*cur_end = term; 
	return done;
}
int apply_filter_to_sts_line ( struct session * t , struct channel * rtr , struct hdr_exp * exp ) { char term ; char * cur_ptr , * cur_end ; int done ; struct http_txn * txn = & t -> txn ; int delta ; if ( unlikely ( txn -> flags & TX_SVDENY ) ) return 1 ; else if ( unlikely ( txn -> flags & TX_SVALLOW ) && ( exp -> action == ACT_ALLOW || exp -> action == ACT_DENY ) ) return 0 ; else if ( exp -> action == ACT_REMOVE ) return 0 ; done = 0 ; cur_ptr = rtr -> buf -> p ; cur_end = cur_ptr + txn -> rsp . sl . st . l ; term = * cur_end ; * cur_end = ' \0 ' ; if ( regexec ( exp -> preg , cur_ptr , MAX_MATCH , pmatch , 0 ) == 0 ) { switch ( exp -> action ) { case ACT_ALLOW : txn -> flags |= TX_SVALLOW ; done = 1 ; break ; case ACT_DENY : txn -> flags |= TX_SVDENY ; done = 1 ; break ; case ACT_REPLACE : * cur_end = term ; trash . len = exp_replace ( trash . str , cur_ptr , exp -> replace , pmatch ) ; delta = buffer_replace2 ( rtr -> buf , cur_ptr , cur_end , trash . str , trash . len ) ; http_msg_move_end ( & txn -> rsp , delta ) ; cur_end += delta ; cur_end = ( char * ) http_parse_stsline ( & txn -> rsp , HTTP_MSG_RPVER , cur_ptr , cur_end + 1 , NULL , NULL ) ; if ( unlikely ( ! cur_end ) ) return -1 ; txn -> status = strl2ui ( rtr -> buf -> p + txn -> rsp . sl . st . c , txn -> rsp . sl . st . c_l ) ; hdr_idx_set_start ( & txn -> hdr_idx , txn -> rsp . sl . st . l , * cur_end == ' \r ' ) ; return 1 ; } } * cur_end = term ; return done ; }
Apply the filter to the status line in the response buffer <rtr>.
Apply the filter to the status line in the response buffer <rtr > .
/* Now we have the status line between cur_ptr and cur_end */ /* The annoying part is that pattern matching needs
	 * that we modify the contents to null-terminate all
	 * strings before testing them.
	 */ /* restore the string terminator */ /* FIXME: if the user adds a newline in the replacement, the
			 * index will not be recalculated for now, and the new line
			 * will not be counted as a new header.
			 */ /* we have a full respnse and we know that we have either a CR
			 * or an LF at <ptr>.
			 */ /* there is no point trying this regex on headers */ /* restore the string terminator */