~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to example/add-header/readme.txt

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
About add-header.c
 
2
 
 
3
This plugin adds a header to a request.
 
4
 
 
5
Enter the text of the header to be added into the plugin.config file; for 
 
6
example,
 
7
enter the following line in plugin.config
 
8
 
 
9
        On NT:  AddHeader.dll "name1: value1" "name2: value2"
 
10
        On Solaris: add-header.so "name1: value1" "name2: value2"
 
11
 
 
12
The TSPluginInit function does the following:
 
13
 
 
14
- creates a MIME field buffer that contains the header to be added, 
 
15
        using the following functions:
 
16
        TSMBufferCreate
 
17
        TSMimeHdrCreate
 
18
        TSMimeHdrFieldCreate
 
19
        TSMimeHdrFieldAppend
 
20
        TSMimeHdrFieldNameSet
 
21
        TSMimeHdrFieldValueAppend
 
22
        
 
23
 
 
24
- sets up the callback for the add-header-plugin function, which 
 
25
        is the main callback function, using 
 
26
        TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK,
 
27
        TSContCreate(add_header_plugin, NULL);
 
28
 
 
29
add_header_plugin is the main function in the plugin. In the 
 
30
event of TS_EVENT_HTTP_READ_REQUEST_HDR (when the HTTP
 
31
state machine reads a request header), it calls the function
 
32
add_header. 
 
33
 
 
34
add_header first makes sure that it can retrieve the client request
 
35
header from the current transaction, using 
 
36
        TSHttpTxnClientReqGet
 
37
 
 
38
 copies the header into the MIME headers of the 
 
39
HTTP request, using the following functions:
 
40
 
 
41
        TSMimeHdrFieldGet
 
42
        TSMimeHdrFieldCreate
 
43
        TSMimeHdrFieldCopy
 
44
        TSMimeHdrFieldAPpend
 
45
        TSMimeHdrFieldNext
 
46
 
 
47
When add_header is done, it uses
 
48
        TSHttpTxnReenable 
 
49
to continue. 
 
50