From: rousskov <> Date: Wed, 3 Jun 1998 05:55:47 +0000 (+0000) Subject: - added a chapter on HTTP headers (alpha version) X-Git-Tag: SQUID_3_0_PRE1~3190 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=19164e88c03257314673e275aeaa4e0ee962901b;p=thirdparty%2Fsquid.git - added a chapter on HTTP headers (alpha version) - spellchecked --- diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml index a4a266f21f..bd14b39b64 100644 --- a/doc/Programming-Guide/prog-guide.sgml +++ b/doc/Programming-Guide/prog-guide.sgml @@ -57,7 +57,7 @@ name="the Squid Developers">.

Function names and file names will be written in a courier font, such as The Big Picture @@ -150,7 +150,7 @@ Squid consists of the following major components reply headers are not the same as the cache metadata.

- Client-side reqeusts register themselves with a cache_object://hostname/operation @@ -322,7 +322,7 @@ Squid consists of the following major components implement blocking disk operations in a set of thread (child) processes. -Configuation File Parsing +Configuration File Parsing

Debugging @@ -360,7 +360,7 @@ Squid consists of the following major components

Squid includes extensive debugging statements to assist in - tracking down bugs and strange behaviour. Every debug statement + tracking down bugs and strange behavior. Every debug statement is assigned a section and level. Usually, every debug statement in the same source file has the same section. Levels are chosen depending on how much output will be generated, or how useful the @@ -397,7 +397,7 @@ Squid consists of the following major components cache replacement, cleaning swap directories, as well as one-time functions such as ICP query timeouts. -Filedescriptor Managment +Filedescriptor Management

-HTTP Headers -

- - General remarks - -

- - Most operations on Life cycle - -

- - /* declare */ - HttpHeader hdr; - - /* initialize (as an HTTP Request header) */ - httpHeaderInit(&hdr, hoRequest); - - /* do something */ - ... - - /* cleanup */ - httpHeaderClean(&hdr); - - -

- Prior to use, an - Once initialized, the - Note that there are no methods for "creating" or "destroying" a - "dynamic" Header Manipulation. - -

- The mostly common operations on HTTP headers are testing for a particular - header-field ( - - - Special care must be taken when several header-fields with the same id are - preset in the header. If HTTP protocol allows only one copy of the specified - field per header (e.g. "Content-Length"), - It is prohibited to ask for a List of values when only one value is permitted, - and visa-versa. This restriction prevents a programmer from processing one - value of an header-field while ignoring other valid values. - -

- - The value being put using one of the - Example: - - - /* add our own Age field if none was added before */ - int age = ... - if (!httpHeaderHas(hdr, HDR_AGE)) - httpHeaderPutInt(hdr, HDR_AGE, age); - - -

- There are two ways to delete a field from a header. To delete a "known" field - (a field with "id" other than - - The - /* delete all fields with a given name */ - HttpHeaderPos pos = HttpHeaderInitPos; - HttpHeaderEntry *e; - while ((e = httpHeaderGetEntry(hdr, &pos))) { - if (!strCaseCmp(e->name, name)) - ... /* delete entry */ - } - - - Note that I/O and Headers. - -

- To store a header in a file or socket, pack it using Adding new header-field ids. - -

- Adding new ids is simple. First add new HDR_ entry to the http_hdr_type - enumeration in enums.h. Then describe a new header-field attributes in - the HeadersAttrs array located in - Finally, add new id to one of the following arrays: - - Also, if the new field is a "list" header, add it to the - - In most cases, if you forget to include a new field id in one of the required - arrays, you will get a run-time assertion. For rarely used fields, however, it - may take a long time for an assertion to be triggered. - -

- There is virtually no limit on the number of fields supported by Squid. If - current mask sizes cannot fit all the ids (you will get an assertion if that - happens), simply enlarge HttpHeaderMask type in A Word on Efficiency. - -

- - Adding new fields is somewhat expensive if they require complex conversions to - a string. - -

- Deleting existing fields requires scan of all the entries and comparing their - "id"s (faster) or "names" (slower) with the one specified for deletion. - -

- Most of the operations are faster than their "ascii string" equivalents. - - - Internet Cache Protocol

These routines implement SNMP for Squid. At the present time, - we have made almost all of the cachemgr information avaialble + we have made almost all of the cachemgr information available via SNMP. URN Support @@ -782,14 +556,14 @@ mirror sites. For more details, please see - Although it would be possible for Squid to send and recieve + Although it would be possible for Squid to send and receive ICMP messages directly, we use an external process for two important reasons: Because squid handles many filedescriptors simultaneously, - we get much more accruate RTT measurements when ICMP is + we get much more accurate RTT measurements when ICMP is handled by a separate process. - Superuser priveleges are required to send and receive + Superuser privileges are required to send and receive ICMP. Rather than require Squid to be started as root, we prefer to have the smaller and simpler -A client connetion is accepted by the @@ -920,7 +694,7 @@ will execute The I/O handlers are reset every time they are called. In other words, a handler function must re-register itself with commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); @@ -1008,7 +782,7 @@ just-freed memory.

The timeout and lifetime handlers are called for file descriptors which -have been idle for too long. They are futher discussed in a following +have been idle for too long. They are further discussed in a following chapter. @@ -1188,4 +962,228 @@ according to the Cache Manager + +HTTP Headers +

+ + General remarks + +

+ + Most operations on Life cycle + +

+ + /* declare */ + HttpHeader hdr; + + /* initialize (as an HTTP Request header) */ + httpHeaderInit(&hdr, hoRequest); + + /* do something */ + ... + + /* cleanup */ + httpHeaderClean(&hdr); + + +

+ Prior to use, an + Once initialized, the + Note that there are no methods for "creating" or "destroying" a + "dynamic" Header Manipulation. + +

+ The mostly common operations on HTTP headers are testing for a particular + header-field ( + + + Special care must be taken when several header-fields with the same id are + preset in the header. If HTTP protocol allows only one copy of the specified + field per header (e.g. "Content-Length"), + It is prohibited to ask for a List of values when only one value is permitted, + and visa-versa. This restriction prevents a programmer from processing one + value of an header-field while ignoring other valid values. + +

+ + The value being put using one of the + Example: + + + /* add our own Age field if none was added before */ + int age = ... + if (!httpHeaderHas(hdr, HDR_AGE)) + httpHeaderPutInt(hdr, HDR_AGE, age); + + +

+ There are two ways to delete a field from a header. To delete a "known" field + (a field with "id" other than + + The + /* delete all fields with a given name */ + HttpHeaderPos pos = HttpHeaderInitPos; + HttpHeaderEntry *e; + while ((e = httpHeaderGetEntry(hdr, &pos))) { + if (!strCaseCmp(e->name, name)) + ... /* delete entry */ + } + + + Note that I/O and Headers. + +

+ To store a header in a file or socket, pack it using Adding new header-field ids. + +

+ Adding new ids is simple. First add new HDR_ entry to the http_hdr_type + enumeration in enums.h. Then describe a new header-field attributes in + the HeadersAttrs array located in + Finally, add new id to one of the following arrays: + + Also, if the new field is a "list" header, add it to the + + In most cases, if you forget to include a new field id in one of the required + arrays, you will get a run-time assertion. For rarely used fields, however, it + may take a long time for an assertion to be triggered. + +

+ There is virtually no limit on the number of fields supported by Squid. If + current mask sizes cannot fit all the ids (you will get an assertion if that + happens), simply enlarge HttpHeaderMask type in A Word on Efficiency. + +

+ + Adding new fields is somewhat expensive if they require complex conversions to + a string. + +

+ Deleting existing fields requires scan of all the entries and comparing their + "id"s (faster) or "names" (slower) with the one specified for deletion. + +

+ Most of the operations are faster than their "ascii string" equivalents. +