src/proto_http.c
int http_remove_header2(struct http_msg *msg, struct hdr_idx *idx, struct hdr_ctx *ctx)
{
	int cur_idx = ctx->idx;
	char *sol = ctx->line;
	struct hdr_idx_elem *hdr;
	int delta, skip_comma;

	if (!cur_idx)
		return 0;

	hdr = &idx->v[cur_idx];
	if (sol[ctx->del] == ':' && ctx->val + ctx->vlen + ctx->tws == hdr->len) {
		/* This was the only value of the header, we must now remove it entirely. */
		delta = buffer_replace2(msg->chn->buf, sol, sol + hdr->len + hdr->cr + 1, NULL, 0);
		http_msg_move_end(msg, delta);
		idx->used--;
		hdr->len = 0;   /* unused entry */
		idx->v[ctx->prev].next = idx->v[ctx->idx].next;
		if (idx->tail == ctx->idx)
			idx->tail = ctx->prev;
		ctx->idx = ctx->prev;    /* walk back to the end of previous header */
		ctx->line -= idx->v[ctx->idx].len + idx->v[cur_idx].cr + 1;
		ctx->val = idx->v[ctx->idx].len; /* point to end of previous header */
		ctx->tws = ctx->vlen = 0;
		return ctx->idx;
	}

	/* This was not the only value of this header. We have to remove between
	 * ctx->del+1 and ctx->val+ctx->vlen+ctx->tws+1 included. If it is the
	 * last entry of the list, we remove the last separator.
	 */

	skip_comma = (ctx->val + ctx->vlen + ctx->tws == hdr->len) ? 0 : 1;
	delta = buffer_replace2(msg->chn->buf, sol + ctx->del + skip_comma,
				sol + ctx->val + ctx->vlen + ctx->tws + skip_comma,
				NULL, 0);
	hdr->len += delta;
	http_msg_move_end(msg, delta);
	ctx->val = ctx->del;
	ctx->tws = ctx->vlen = 0;
	return ctx->idx;
}
/* Remove one value of a header. This only works on a <ctx> returned by one of
 * the http_find_header functions. The value is removed, as well as surrounding
 * commas if any. If the removed value was alone, the whole header is removed.
 * The ctx is always updated accordingly, as well as the buffer and HTTP
 * message <msg>. The new index is returned. If it is zero, it means there is
 * no more header, so any processing may stop. The ctx is always left in a form
 * that can be handled by http_find_header2() to find next occurrence.
 */
Remove one value of a header. This only works on a  returned by one of
the http_find_header functions. The value is removed, as well as surrounding
commas if any. If the removed value was alone, the whole header is removed.
The ctx is always updated accordingly, as well as the buffer and HTTP
message . The new index is returned. If it is zero, it means there is
no more header, so any processing may stop. The ctx is always left in a form
that can be handled by http_find_header2() to find next occurrence.
Remove one value of a header . This only works on a returned by one of the http_find_header functions . The value is removed as well as surrounding commas if any . If the removed value was alone the whole header is removed . The ctx is always updated accordingly as well as the buffer and HTTP message . The new index is returned . If it is zero it means there is no more header so any processing may stop . The ctx is always left in a form that can be handled by http_find_header2 () to find next occurrence .
int http_remove_header2(struct http_msg *msg, struct hdr_idx *idx, struct hdr_ctx *ctx)
{
	int cur_idx = ctx->idx;
	char *sol = ctx->line;
	struct hdr_idx_elem *hdr;
	int delta, skip_comma;
	if (!cur_idx)
		return 0;
	hdr = &idx->v[cur_idx];
	if (sol[ctx->del] == ':' && ctx->val + ctx->vlen + ctx->tws == hdr->len) {
		delta = buffer_replace2(msg->chn->buf, sol, sol + hdr->len + hdr->cr + 1, NULL, 0);
		http_msg_move_end(msg, delta);
		idx->used--;
		hdr->len = 0;   
		idx->v[ctx->prev].next = idx->v[ctx->idx].next;
		if (idx->tail == ctx->idx)
			idx->tail = ctx->prev;
		ctx->idx = ctx->prev;    
		ctx->line -= idx->v[ctx->idx].len + idx->v[cur_idx].cr + 1;
		ctx->val = idx->v[ctx->idx].len; 
		ctx->tws = ctx->vlen = 0;
		return ctx->idx;
	}
	skip_comma = (ctx->val + ctx->vlen + ctx->tws == hdr->len) ? 0 : 1;
	delta = buffer_replace2(msg->chn->buf, sol + ctx->del + skip_comma,
				sol + ctx->val + ctx->vlen + ctx->tws + skip_comma,
				NULL, 0);
	hdr->len += delta;
	http_msg_move_end(msg, delta);
	ctx->val = ctx->del;
	ctx->tws = ctx->vlen = 0;
	return ctx->idx;
}
int http_remove_header2 ( struct http_msg * msg , struct hdr_idx * idx , struct hdr_ctx * ctx ) { int cur_idx = ctx -> idx ; char * sol = ctx -> line ; struct hdr_idx_elem * hdr ; int delta , skip_comma ; if ( ! cur_idx ) return 0 ; hdr = & idx -> v [ cur_idx ] ; if ( sol [ ctx -> del ] == ' ' && ctx -> val + ctx -> vlen + ctx -> tws == hdr -> len ) { delta = buffer_replace2 ( msg -> chn -> buf , sol , sol + hdr -> len + hdr -> cr + 1 , NULL , 0 ) ; http_msg_move_end ( msg , delta ) ; idx -> used -- ; hdr -> len = 0 ; idx -> v [ ctx -> prev ] . next = idx -> v [ ctx -> idx ] . next ; if ( idx -> tail == ctx -> idx ) idx -> tail = ctx -> prev ; ctx -> idx = ctx -> prev ; ctx -> line -= idx -> v [ ctx -> idx ] . len + idx -> v [ cur_idx ] . cr + 1 ; ctx -> val = idx -> v [ ctx -> idx ] . len ; ctx -> tws = ctx -> vlen = 0 ; return ctx -> idx ; } skip_comma = ( ctx -> val + ctx -> vlen + ctx -> tws == hdr -> len ) ? 0 : 1 ; delta = buffer_replace2 ( msg -> chn -> buf , sol + ctx -> del + skip_comma , sol + ctx -> val + ctx -> vlen + ctx -> tws + skip_comma , NULL , 0 ) ; hdr -> len += delta ; http_msg_move_end ( msg , delta ) ; ctx -> val = ctx -> del ; ctx -> tws = ctx -> vlen = 0 ; return ctx -> idx ; }
Remove one value of a header.
Remove one value of a header .
/* This was the only value of the header, we must now remove it entirely. */ /* unused entry */ /* walk back to the end of previous header */ /* point to end of previous header */ /* This was not the only value of this header. We have to remove between
	 * ctx->del+1 and ctx->val+ctx->vlen+ctx->tws+1 included. If it is the
	 * last entry of the list, we remove the last separator.
	 */