mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-28 15:42:30 +00:00
8d5d7f20b9
The HTTP parser has been rewritten for better compliance to RFC2616. The same parser is now usable for both requests and responses, and it now supports HTTP/0.9 as well as multi-line headers. It has also been improved for speed ; a typicial HTTP request is parsed in about 2 microseconds on a 1 GHz processor. The monitor-uri check has been moved so that the requests are not logged. The httpclose option now tries to change as little as possible in the request, and does not affect the first header if it is already set to 'close'. HTTP/0.9 requests are converted to HTTP/1.0 before being forwarded. Headers and request transformations are now distinct. The headers list is updated after each insertion/removal/transformation. The request is re-parsed and checked after each transformation. It is not possible anymore to remove a request, and requests which lead to invalid request lines are now rejected.
95 lines
2.9 KiB
C
95 lines
2.9 KiB
C
/*
|
|
include/proto/hdr_idx.h
|
|
This file defines function prototypes for fast header indexation.
|
|
|
|
Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation, version 2.1
|
|
exclusively.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _PROTO_HDR_IDX_H
|
|
#define _PROTO_HDR_IDX_H
|
|
|
|
#include <common/config.h>
|
|
#include <types/hdr_idx.h>
|
|
|
|
/*
|
|
* Initialize the list pointers.
|
|
* list->size must already be set. If list->size is set and list->v is
|
|
* non-null, list->v is also initialized..
|
|
*/
|
|
static inline void hdr_idx_init(struct hdr_idx *list)
|
|
{
|
|
if (list->size && list->v) {
|
|
register struct hdr_idx_elem e = { .len=0, .cr=0, .next=0};
|
|
list->v[0] = e;
|
|
}
|
|
list->tail = 0;
|
|
list->used = list->last = 1;
|
|
}
|
|
|
|
/*
|
|
* Return index of the first entry in the list. Usually, it means the index of
|
|
* the first header just after the request or response. If zero is returned, it
|
|
* means that the list is empty.
|
|
*/
|
|
static inline int hdr_idx_first_idx(struct hdr_idx *list)
|
|
{
|
|
return list->v[0].next;
|
|
}
|
|
|
|
/*
|
|
* Return position of the first entry in the list. Usually, it means the
|
|
* position of the first header just after the request, but it can also be the
|
|
* end of the headers if the request has no header. hdr_idx_start_idx() should
|
|
* be checked before to ensure there is a valid header.
|
|
*/
|
|
static inline int hdr_idx_first_pos(struct hdr_idx *list)
|
|
{
|
|
return list->v[0].len + list->v[0].cr + 1;
|
|
}
|
|
|
|
/*
|
|
* Sets the information about the start line. Its length and the presence of
|
|
* the CR are registered so that hdr_idx_first_pos() knows exactly where to
|
|
* find the first header.
|
|
*/
|
|
static inline void hdr_idx_set_start(struct hdr_idx *list, int len, int cr)
|
|
{
|
|
list->v[0].len = len;
|
|
list->v[0].cr = cr;
|
|
}
|
|
|
|
/*
|
|
* Add a header entry to <list> after element <after>. <after> is ignored when
|
|
* the list is empty or full. Common usage is to set <after> to list->tail.
|
|
*
|
|
* Returns the position of the new entry in the list (from 1 to size-1), or 0
|
|
* if the array is already full. An effort is made to fill the array linearly,
|
|
* but once the last entry has been used, we have to search for unused blocks,
|
|
* which takes much more time. For this reason, it's important to size is
|
|
* appropriately.
|
|
*/
|
|
int hdr_idx_add(int len, int cr, struct hdr_idx *list, int after);
|
|
|
|
#endif /* _PROTO_HDR_IDX_H */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*/
|