bin/varnishd/cache/cache_http.c
void
HTTP_Encode(const struct http *fm, uint8_t *p0, unsigned l, unsigned how)
{
	unsigned u, w;
	uint16_t n;
	uint8_t *p, *e;

	AN(p0);
	AN(l);
	p = p0;
	e = p + l;
	assert(p + 5 <= e);
	assert(fm->nhd <= fm->shd);
	n = HTTP_HDR_FIRST - 3;
	vbe16enc(p + 2, fm->status);
	p += 4;
	CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
	for (u = 0; u < fm->nhd; u++) {
		if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL)
			continue;
		Tcheck(fm->hd[u]);
		if (http_isfiltered(fm, u, how))
			continue;
		http_VSLH(fm, u);
		w = Tlen(fm->hd[u]) + 1L;
		assert(p + w + 1 <= e);
		memcpy(p, fm->hd[u].b, w);
		p += w;
		n++;
	}
	*p++ = '\0';
	assert(p <= e);
	vbe16enc(p0, n + 1);
}
/*--------------------------------------------------------------------
 * Encode http struct as byte string.
 *
 * XXX: We could save considerable special-casing below by encoding also
 * XXX: H__Status, H__Reason and H__Proto into the string, but it would
 * XXX: add 26-30 bytes to all encoded objects to save a little code.
 * XXX: It could possibly be a good idea for later HTTP versions.
 */
Encode http struct as byte string.
XXX: We could save considerable special-casing below by encoding also
XXX: H__Status, H__Reason and H__Proto into the string, but it would
XXX: add 26-30 bytes to all encoded objects to save a little code.
XXX: It could possibly be a good idea for later HTTP versions.
Encode http struct as byte string . XXX : We could save considerable special - casing below by encoding also XXX : H__Status H__Reason and H__Proto into the string but it would XXX : add 26 - 30 bytes to all encoded objects to save a little code . XXX : It could possibly be a good idea for later HTTP versions .
void
HTTP_Encode(const struct http *fm, uint8_t *p0, unsigned l, unsigned how)
{
	unsigned u, w;
	uint16_t n;
	uint8_t *p, *e;
	AN(p0);
	AN(l);
	p = p0;
	e = p + l;
	assert(p + 5 <= e);
	assert(fm->nhd <= fm->shd);
	n = HTTP_HDR_FIRST - 3;
	vbe16enc(p + 2, fm->status);
	p += 4;
	CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
	for (u = 0; u < fm->nhd; u++) {
		if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL)
			continue;
		Tcheck(fm->hd[u]);
		if (http_isfiltered(fm, u, how))
			continue;
		http_VSLH(fm, u);
		w = Tlen(fm->hd[u]) + 1L;
		assert(p + w + 1 <= e);
		memcpy(p, fm->hd[u].b, w);
		p += w;
		n++;
	}
	*p++ = '\0';
	assert(p <= e);
	vbe16enc(p0, n + 1);
}
void HTTP_Encode ( const struct http * fm , uint8_t * p0 , unsigned l , unsigned how ) { unsigned u , w ; uint16_t n ; uint8_t * p , * e ; AN ( p0 ) ; AN ( l ) ; p = p0 ; e = p + l ; assert ( p + 5 <= e ) ; assert ( fm -> nhd <= fm -> shd ) ; n = HTTP_HDR_FIRST - 3 ; vbe16enc ( p + 2 , fm -> status ) ; p += 4 ; CHECK_OBJ_NOTNULL ( fm , HTTP_MAGIC ) ; for ( u = 0 ; u < fm -> nhd ; u ++ ) { if ( u == HTTP_HDR_METHOD || u == HTTP_HDR_URL ) continue ; Tcheck ( fm -> hd [ u ] ) ; if ( http_isfiltered ( fm , u , how ) ) continue ; http_VSLH ( fm , u ) ; w = Tlen ( fm -> hd [ u ] ) + 1L ; assert ( p + w + 1 <= e ) ; memcpy ( p , fm -> hd [ u ] . b , w ) ; p += w ; n ++ ; } * p ++ = ' \0 ' ; assert ( p <= e ) ; vbe16enc ( p0 , n + 1 ) ; }
Encode http struct as byte string.
Encode http struct as byte string .