bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / tomcat-connectors-1.2.32-src / xdocs / ajp / ajpv13a.xml
1 <?xml version="1.0"?> 
2 <!DOCTYPE document [
3   <!ENTITY project SYSTEM "project.xml">
4 ]>
5 <document url="ajpv13a.html">
6
7   &project;
8  <copyright>
9    Licensed to the Apache Software Foundation (ASF) under one or more
10    contributor license agreements.  See the NOTICE file distributed with
11    this work for additional information regarding copyright ownership.
12    The ASF licenses this file to You under the Apache License, Version 2.0
13    (the "License"); you may not use this file except in compliance with
14    the License.  You may obtain a copy of the License at
15  
16        http://www.apache.org/licenses/LICENSE-2.0
17  
18    Unless required by applicable law or agreed to in writing, software
19    distributed under the License is distributed on an "AS IS" BASIS,
20    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21    See the License for the specific language governing permissions and
22    limitations under the License.
23 </copyright>
24 <properties>
25 <title>AJPv13</title>
26 <author email="danmil@shore.net">danmil@shore.net</author>
27 <author email="jfrederic.clere@fujitsu-siemens.com">Jean-Frederic Clere</author>
28 <date>$Date: 2007-06-09 22:38:06 +0200 (Sat, 09 Jun 2007) $</date>
29 </properties>
30 <body>
31 <section name="Intro">
32
33 <p>
34 The original document was written by
35 Dan Milstein, <author email="danmil@shore.net">danmil@shore.net</author>
36 on December 2000. The present document is generated out of an xml file
37 to allow a more easy integration in the Tomcat documentation.
38
39 </p>
40
41 <p>
42 This describes the Apache JServ Protocol version 1.3 (hereafter
43 <b>ajp13</b>).  There is, apparently, no current documentation of how the
44 protocol works.  This document is an attempt to remedy that, in order to
45 make life easier for maintainers of JK, and for anyone who wants to
46 port the protocol somewhere (into jakarta 4.x, for example).
47 </p>
48
49 </section>
50
51 <section name="author">
52
53 <p>
54 I am not one of the designers of this protocol -- I believe that Gal
55 Shachor was the original designer.  Everything in this document is derived
56 from the actual implementation I found in the tomcat 3.x code.  I hope it
57 is useful, but I can't make any grand claims to perfect accuracy.  I also
58 don't know why certain design decisions were made.  Where I was able, I've
59 offered some possible justifications for certain choices, but those are
60 only my guesses.  In general, the C code which Shachor wrote is very clean
61 and comprehensible (if almost totally undocumented).  I've cleaned up the
62 Java code, and I think it's reasonably readable.
63 </p>
64 </section>
65
66 <section name="Design Goals">
67
68 <p>
69 According to email from Gal Shachor to the jakarta-dev mailing list,
70 the original goals of <b>JK</b> (and thus <b>ajp13</b>) were to extend
71 <b>mod_jserv</b> and <b>ajp12</b> by (I am only including the goals which
72 relate to communication between the web server and the servlet container):
73
74 <ul>
75   <li> Increasing performance (speed, specifically). </li>
76
77   <li> Adding support for SSL, so that <code>isSecure()</code> and
78        <code>getScheme()</code> will function correctly within the servlet
79        container.  The client certificates and cipher suite will be
80        available to servlets as request attributes. </li>
81
82 </ul>
83 </p>
84 </section>
85
86 <section name="Overview of the protocol">
87
88 <p>
89 The <b>ajp13</b> protocol is packet-oriented.  A binary format was
90 presumably chosen over the more readable plain text for reasons of
91 performance.  The web server communicates with the servlet container over
92 TCP connections.  To cut down on the expensive process of socket creation,
93 the web server will attempt to maintain persistent TCP connections to the
94 servlet container, and to reuse a connection for multiple request/response
95 cycles.
96 </p><p>
97 Once a connection is assigned to a particular request, it will not be
98 used for any others until the request-handling cycle has terminated.  In
99 other words, requests are not multiplexed over connections.  This makes
100 for much simpler code at either end of the connection, although it does
101 cause more connections to be open at once.
102 </p><p>
103 Once the web server has opened a connection to the servlet container,
104 the connection can be in one of the following states:
105 </p><p>
106 <ul>
107   <li> Idle <br/> No request is being handled over this connection. </li>
108   <li> Assigned <br/> The connecton is handling a specific request.</li>
109 </ul>
110
111 </p><p>
112 Once a connection is assigned to handle a particular request, the basic
113 request informaton (e.g. HTTP headers, etc) is sent over the connection in
114 a highly condensed form (e.g. common strings are encoded as integers).
115 Details of that format are below in Request Packet Structure. If there is a
116 body to the request (content-length > 0), that is sent in a separate
117 packet immediately after.
118 </p><p>
119 At this point, the servlet container is presumably ready to start
120 processing the request.  As it does so, it can send the
121 following messages back to the web server:
122
123 <ul>
124   <li>SEND_HEADERS <br/>Send a set of headers back to the browser.</li>
125
126   <li>SEND_BODY_CHUNK <br/>Send a chunk of body data back to the browser.</li>
127
128   <li>GET_BODY_CHUNK <br/>Get further data from the request if it hasn't all
129   been transferred yet.  This is necessary because the packets have a fixed
130   maximum size and arbitrary amounts of data can be included the body of a
131   request (for uploaded files, for example).  (Note: this is unrelated to
132   HTTP chunked tranfer).</li>
133
134   <li>END_RESPONSE <br/> Finish the request-handling cycle.</li>
135 </ul>
136 </p><p>
137
138 Each message is accompanied by a differently formatted packet of data.  See
139 Response Packet Structures below for details.
140 </p>
141 </section>
142
143 <section name="Basic Packet Structure">
144
145 <p>
146 There is a bit of an XDR heritage to this protocol, but it differs in
147 lots of ways (no 4 byte alignment, for example).
148 </p><p>
149 Byte order: I am not clear about the endian-ness of the individual
150 bytes.  I'm guessing the bytes are little-endian, because that's what XDR
151 specifies, and I'm guessing that sys/socket library is magically making
152 that so (on the C side).  If anyone with a better knowledge of socket calls
153 can step in, that would be great.
154 </p><p>
155 There are four data types in the protocol: bytes, booleans, integers and
156 strings.
157
158 <dl>
159   <dt><b>Byte</b></dt>
160   <dd>A single byte.</dd>
161
162   <dt><b>Boolean</b></dt>
163   <dd>A single byte, 1 = true, 0 = false.  Using other non-zero values as
164   true (i.e. C-style) may work in some places, but it won't in
165   others.</dd>
166   
167   <dt><b>Integer</b></dt>
168   <dd>A number in the range of 0 to 2^16 (32768).  Stored in 2 bytes with
169   the high-order byte first.</dd>
170
171   <dt><b>String</b></dt>
172   <dd>A variable-sized string (length bounded by 2^16). Encoded with the
173   length packed into two bytes first, followed by the string (including the
174   terminating '\0').  Note that the encoded length does <b>not</b> include
175   the trailing '\0' -- it is like <code>strlen</code>.  This is a touch
176   confusing on the Java side, which is littered with odd autoincrement
177   statements to skip over these terminators.  I believe the reason this was
178   done was to allow the C code to be extra efficient when reading strings
179   which the servlet container is sending back -- with the terminating \0
180   character, the C code can pass around references into a single buffer,
181   without copying.  If the \0 was missing, the C code would have to copy
182   things out in order to get its notion of a string. Note a size of -1
183   (65535) indicates a null string and no data follow the length in this
184   case.</dd>
185 </dl>
186 </p>
187
188 <subsection name="Packet Size">
189 <p>
190 According to much of the code, the max packet
191 size is 8 * 1024 bytes (8K).  The actual length of the packet is encoded in the
192 header.
193 </p>
194 </subsection>
195
196 <subsection name="Packet Headers">
197 <p>
198 Packets sent from the server to the container begin with
199 <code>0x1234</code>.  Packets sent from the container to the server begin
200 with <code>AB</code> (that's the ASCII code for A followed by the ASCII
201 code for B).  After those first two bytes, there is an integer (encoded as
202 above) with the length of the payload.  Although this might suggest that
203 the maximum payload could be as large as 2^16, in fact, the code sets the
204 maximum to be 8K.
205
206
207 <table>
208   <tr>
209     <th colspan="6">Packet Format (Server->Container)</th>
210   </tr>
211
212   <tr>
213     <th>Byte</th>
214     <td>0</td>
215     <td>1</td>
216     <td>2</td>
217     <td>3</td>
218     <td>4...(n+3)</td>
219   </tr>
220
221   <tr>
222     <th>Contents</th>
223     <td>0x12</td>
224     <td>0x34</td>
225     <td colspan="2">Data Length (n)</td>
226     <td>Data</td>
227   </tr>
228 </table>
229
230 <table>
231   <tr>
232     <th colspan="6"><b>Packet Format (Container->Server)</b></th>
233   </tr>
234
235   <tr>
236     <th>Byte</th>
237     <td>0</td>
238     <td>1</td>
239     <td>2</td>
240     <td>3</td>
241     <td>4...(n+3)</td>
242   </tr>
243
244   <tr>
245     <th>Contents</th>
246     <td>A</td>
247     <td>B</td>
248     <td colspan="2">Data Length (n)</td>
249     <td>Data</td>
250   </tr>
251 </table>
252 </p>
253 <p>
254 <A NAME="prefix-codes"></A> For most packets, the first byte of the
255 payload encodes the type of message.  The exception is for request body
256 packets sent from the server to the container -- they are sent with a
257 standard packet header (0x1234 and then length of the packet), but without
258 any prefix code after that (this seems like a mistake to me).
259 </p><p>
260 The web server can send the following messages to the servlet container:
261
262 <table>
263   <tr>
264     <th>Code</th>
265     <th>Type of Packet</th>
266     <th>Meaning</th>
267   </tr>
268   <tr>
269     <td>2</td>
270     <td>Forward Request</td>
271     <td>Begin the request-processing cycle with the following data</td>
272   </tr>
273   <tr>
274     <td>7</td>
275     <td>Shutdown</td>
276     <td>The web server asks the container to shut itself down.</td>
277   </tr>
278   <tr>
279     <td>8</td>
280     <td>Ping</td>
281     <td>The web server asks the container to take control (secure login phase).</td>
282   </tr>
283   <tr>
284     <td>10</td>
285     <td>CPing</td>
286     <td>The web server asks the container to respond quickly with a CPong.</td>
287   </tr>
288   <tr>
289     <td>none</td>
290     <td>Data</td>
291     <td>Size (2 bytes) and corresponding body data.</td>
292   </tr>
293 </table>
294 </p>
295 <p>
296 To ensure some
297 basic security, the container will only actually do the <code>Shutdown</code> if the
298 request comes from the same machine on which it's hosted.
299 </p>
300 <p>
301 The first <code>Data</code> packet is send immediatly after the <code>Forward Request</code> by the web server.
302 </p>
303
304 <p>The servlet container can send the following types of messages to the web
305 server:
306 <table>
307   <tr>
308     <th>Code</th>
309     <th>Type of Packet</th>
310     <th>Meaning</th>
311   </tr>
312   <tr>
313     <td>3</td>
314     <td>Send Body Chunk</td>
315     <td>Send a chunk of the body from the servlet container to the web
316     server (and presumably, onto the browser). </td>
317   </tr>
318   <tr>
319     <td>4</td>
320     <td>Send Headers</td>
321     <td>Send the response headers from the servlet container to the web
322     server (and presumably, onto the browser).</td>
323   </tr>
324   <tr>
325     <td>5</td>
326     <td>End Response</td>
327     <td>Marks the end of the response (and thus the request-handling cycle).</td>
328   </tr>
329   <tr>
330     <td>6</td>
331     <td>Get Body Chunk</td>
332     <td>Get further data from the request if it hasn't all been transferred
333     yet.</td>
334   </tr>
335   <tr>
336     <td>9</td>
337     <td>CPong Reply</td>
338     <td>The reply to a CPing request</td>
339   </tr>
340 </table>
341 </p>
342 <p>
343 Each of the above messages has a different internal structure, detailed below.
344 </p>
345 </subsection>
346 </section>
347
348 <section name="Request Packet Structure">
349
350 <p>
351 For messages from the server to the container of type "Forward Request":
352 </p><p>
353 <source>
354 AJP13_FORWARD_REQUEST :=
355     prefix_code      (byte) 0x02 = JK_AJP13_FORWARD_REQUEST
356     method           (byte)
357     protocol         (string)
358     req_uri          (string)
359     remote_addr      (string)
360     remote_host      (string)
361     server_name      (string)
362     server_port      (integer)
363     is_ssl           (boolean)
364     num_headers      (integer)
365     request_headers *(req_header_name req_header_value)
366     attributes      *(attribut_name attribute_value)
367     request_terminator (byte) OxFF
368 </source>
369 </p><p>
370 The <code>request_headers</code> have the following structure:
371 </p><p>
372 <source>
373 req_header_name := 
374     sc_req_header_name | (string)  [see below for how this is parsed]
375
376 sc_req_header_name := 0xA0xx (integer)
377
378 req_header_value := (string)
379 </source>
380 </p><p>
381
382 The <code>attributes</code> are optional and have the following structure:
383 </p><p>
384 <source>
385 attribute_name := sc_a_name | (sc_a_req_attribute string)
386
387 attribute_value := (string)
388
389 </source>
390 </p><p>
391 Not that the all-important header is "content-length', because it
392 determines whether or not the container looks for another packet
393 immediately.
394 </p><p>
395 Detailed description of the elements of Forward Request.
396 </p>
397 <subsection name="request_prefix">
398 <p>
399 For all requests, this will be 2.
400 See above for details on other <A HREF="#prefix-codes">prefix codes</A>.
401 </p>
402 </subsection>
403
404 <subsection name="method">
405 <p>
406 The HTTP method, encoded as a single byte:
407 </p>
408
409 <p>
410 <table>
411   <tr><th>Command Name</th><th>Code</th></tr>
412   <tr><td>OPTIONS</td><td>1</td></tr>
413   <tr><td>GET</td><td>2</td></tr>
414   <tr><td>HEAD</td><td>3</td></tr>
415   <tr><td>POST</td><td>4</td></tr>
416   <tr><td>PUT</td><td>5</td></tr>
417   <tr><td>DELETE</td><td>6</td></tr>
418   <tr><td>TRACE</td><td>7</td></tr>
419   <tr><td>PROPFIND</td><td>8</td></tr>
420   <tr><td>PROPPATCH</td><td>9</td></tr>
421   <tr><td>MKCOL</td><td>10</td></tr>
422   <tr><td>COPY</td><td>11</td></tr>
423   <tr><td>MOVE</td><td>12</td></tr>
424   <tr><td>LOCK</td><td>13</td></tr>
425   <tr><td>UNLOCK</td><td>14</td></tr>
426   <tr><td>ACL</td><td>15</td></tr>
427   <tr><td>REPORT</td><td>16</td></tr>
428   <tr><td>VERSION-CONTROL</td><td>17</td></tr>
429   <tr><td>CHECKIN</td><td>18</td></tr>
430   <tr><td>CHECKOUT</td><td>19</td></tr>
431   <tr><td>UNCHECKOUT</td><td>20</td></tr>
432   <tr><td>SEARCH</td><td>21</td></tr>
433   <tr><td>MKWORKSPACE</td><td>22</td></tr>
434   <tr><td>UPDATE</td><td>23</td></tr>
435   <tr><td>LABEL</td><td>24</td></tr>
436   <tr><td>MERGE</td><td>25</td></tr>
437   <tr><td>BASELINE_CONTROL</td><td>26</td></tr>
438   <tr><td>MKACTIVITY</td><td>27</td></tr>
439 </table>
440 </p>
441
442 <p>Later version of ajp13, when used with mod_jk2, will transport 
443 additional methods, even if they are not in this list.
444 </p>
445
446 </subsection>
447
448 <subsection  name="protocol, req_uri, remote_addr, remote_host, server_name, server_port, is_ssl">
449 <p>
450   These are all fairly self-explanatory.  Each of these is required, and
451   will be sent for every request.
452 </p>
453 </subsection>
454
455 <subsection name="Headers">
456 <p>
457   The structure of <code>request_headers</code> is the following:
458   First, the number of headers <code>num_headers</code> is encoded.
459   Then, a series of header name <code>req_header_name</code> / value
460   <code>req_header_value</code> pairs follows.
461   Common header names are encoded as integers,
462   to save space.  If the header name is not in the list of basic headers,
463   it is encoded normally (as a string, with prefixed length).  The list of
464   common headers <code>sc_req_header_name</code>and their codes
465   is as follows (all are case-sensitive):
466 </p><p>
467 <table>
468   <tr><th>Name</th><th>Code value</th><th>Code name</th></tr>
469   <tr><td>accept</td><td>0xA001</td><td>SC_REQ_ACCEPT</td></tr>
470   <tr><td>accept-charset</td><td>0xA002</td><td>SC_REQ_ACCEPT_CHARSET</td></tr>
471   <tr><td>accept-encoding</td><td>0xA003</td><td>SC_REQ_ACCEPT_ENCODING</td></tr>
472   <tr><td>accept-language</td><td>0xA004</td><td>SC_REQ_ACCEPT_LANGUAGE</td></tr>
473   <tr><td>authorization</td><td>0xA005</td><td>SC_REQ_AUTHORIZATION</td></tr>
474   <tr><td>connection</td><td>0xA006</td><td>SC_REQ_CONNECTION</td></tr>
475   <tr><td>content-type</td><td>0xA007</td><td>SC_REQ_CONTENT_TYPE</td></tr>
476   <tr><td>content-length</td><td>0xA008</td><td>SC_REQ_CONTENT_LENGTH</td></tr>
477   <tr><td>cookie</td><td>0xA009</td><td>SC_REQ_COOKIE</td></tr>
478   <tr><td>cookie2</td><td>0xA00A</td><td>SC_REQ_COOKIE2</td></tr>
479   <tr><td>host</td><td>0xA00B</td><td>SC_REQ_HOST</td></tr>
480   <tr><td>pragma</td><td>0xA00C</td><td>SC_REQ_PRAGMA</td></tr>
481   <tr><td>referer</td><td>0xA00D</td><td>SC_REQ_REFERER</td></tr>
482   <tr><td>user-agent</td><td>0xA00E</td><td>SC_REQ_USER_AGENT</td></tr>
483 </table>
484 </p><p>
485   The Java code that reads this grabs the first two-byte integer and if
486   it sees an <code>'0xA0'</code> in the most significant
487   byte, it uses the integer in the second byte as an index into an array of
488   header names.  If the first byte is not '0xA0', it assumes that the
489   two-byte integer is the length of a string, which is then read in.
490 </p><p>
491   This works on the assumption that no header names will have length
492   greater than 0x9999 (==0xA000 - 1), which is perfectly reasonable, though
493   somewhat arbitrary. (If you, like me, started to think about the cookie
494   spec here, and about how long headers can get, fear not -- this limit is
495   on header <b>names</b> not header <b>values</b>.  It seems unlikely that
496   unmanageably huge header names will be showing up in the HTTP spec any time
497   soon).
498 </p><p>
499   <b>Note:</b> The <code>content-length</code> header is extremely
500   important.  If it is present and non-zero, the container assumes that
501   the request has a body (a POST request, for example), and immediately
502   reads a separate packet off the input stream to get that body.
503 </p>
504 </subsection>
505
506 <subsection name="Attributes">
507 <p>
508
509   The attributes prefixed with a <code>?</code>
510   (e.g. <code>?context</code>) are all optional.  For each, there is a
511   single byte code to indicate the type of attribute, and then a string to
512   give its value.  They can be sent in any order (thogh the C code always
513   sends them in the order listed below).  A special terminating code is
514   sent to signal the end of the list of optional attributes. The list of
515   byte codes is:
516 </p><p>
517
518 <table>
519   <tr><th>Information</th><th>Code Value</th><th>Note</th></tr>
520   <tr><td>?context</td><td>0x01</td><td>Not currently implemented</td></tr>
521   <tr><td>?servlet_path</td><td>0x02</td><td>Not currently implemented</td></tr>
522   <tr><td>?remote_user</td><td>0x03</td><td></td></tr>
523   <tr><td>?auth_type</td><td>0x04</td><td></td></tr>
524   <tr><td>?query_string</td><td>0x05</td><td></td></tr>
525   <tr><td>?route</td><td>0x06</td><td></td></tr>
526   <tr><td>?ssl_cert</td><td>0x07</td><td></td></tr>
527   <tr><td>?ssl_cipher</td><td>0x08</td><td></td></tr>
528   <tr><td>?ssl_session</td><td>0x09</td><td></td></tr>
529   <tr><td>?req_attribute</td><td>0x0A</td><td>Name (the name of the attribut follows)</td></tr>
530   <tr><td>?ssl_key_size</td><td>0x0B</td><td></td></tr>
531   <tr><td>?secret</td><td>0x0C</td><td></td></tr>
532   <tr><td>?stored_method</td><td>0x0D</td><td></td></tr>
533   <tr><td>are_done</td><td>0xFF</td><td>request_terminator</td></tr>
534 </table>
535
536 </p><p>
537
538   The <code>context</code> and <code>servlet_path</code> are not currently
539   set by the C code, and most of the Java code completely ignores whatever
540   is sent over for those fields (and some of it will actually break if a
541   string is sent along after one of those codes).  I don't know if this is
542   a bug or an unimplemented feature or just vestigial code, but it's
543   missing from both sides of the connection.
544 </p><p>
545   The <code>remote_user</code> and <code>auth_type</code> presumably refer
546   to HTTP-level authentication, and communicate the remote user's username
547   and the type of authentication used to establish their identity (e.g. Basic,
548   Digest).  I'm not clear on why the password isn't also sent, but I don't
549   know HTTP authentication inside and out.
550 </p><p>
551   The <code>query_string</code>, <code>ssl_cert</code>,
552   <code>ssl_cipher</code>, and <code>ssl_session</code> refer to the
553   corresponding pieces of HTTP and HTTPS.
554 </p><p>
555   The <code>route</code>, as I understand it, is used to support sticky
556   sessions -- associating a user's sesson with a particular Tomcat instance
557   in the presence of multiple, load-balancing servers.  I don't know the
558   details.
559 </p><p>
560   Beyond this list of basic attributes, any number of other attributes can
561   be sent via the <code>req_attribute</code> code (0x0A).  A pair of strings
562   to represent the attribute name and value are sent immediately after each
563   instance of that code.  Environment values are passed in via this method.
564 </p><p>
565   Finally, after all the attributes have been sent, the attribute terminator,
566   0xFF, is sent.  This signals both the end of the list of attributes and
567   also then end of the Request Packet.
568 </p>
569 </subsection>
570
571 </section>
572
573 <section name="Response Packet Structure">
574
575 <p>
576 For messages which the container can send back to the server.
577
578 <source>
579 AJP13_SEND_BODY_CHUNK := 
580   prefix_code   3
581   chunk_length  (integer)
582   chunk        *(byte)
583
584
585 AJP13_SEND_HEADERS :=
586   prefix_code       4
587   http_status_code  (integer)
588   http_status_msg   (string)
589   num_headers       (integer)
590   response_headers *(res_header_name header_value)
591
592 res_header_name := 
593     sc_res_header_name | (string)   [see below for how this is parsed]
594
595 sc_res_header_name := 0xA0 (byte)
596
597 header_value := (string)
598
599 AJP13_END_RESPONSE :=
600   prefix_code       5
601   reuse             (boolean)
602
603
604 AJP13_GET_BODY_CHUNK :=
605   prefix_code       6
606   requested_length  (integer)
607 </source>
608
609 </p>
610 <p>
611 Details:
612 </p>
613
614 <subsection name="Send Body Chunk">
615 <p>
616   The chunk is basically binary data, and is sent directly back to the browser.
617 </p>
618 </subsection>
619
620 <subsection name="Send Headers">
621 <p>
622   The status code and message are the usual HTTP things (e.g. "200" and "OK").
623   The response header names are encoded the same way the request header names are.
624   See <A HREF="#header_encoding">above</A> for details about how the the
625   codes are distinguished from the strings.  The codes for common headers are:
626 </p>
627
628 <p>
629 <table>
630   <tr><th>Name</th><th>Code value</th></tr>
631   <tr><td>Content-Type</td><td>0xA001</td></tr>
632   <tr><td>Content-Language</td><td>0xA002</td></tr>
633   <tr><td>Content-Length</td><td>0xA003</td></tr>
634   <tr><td>Date</td><td>0xA004</td></tr>
635   <tr><td>Last-Modified</td><td>0xA005</td></tr>
636   <tr><td>Location</td><td>0xA006</td></tr>
637   <tr><td>Set-Cookie</td><td>0xA007</td></tr>
638   <tr><td>Set-Cookie2</td><td>0xA008</td></tr>
639   <tr><td>Servlet-Engine</td><td>0xA009</td></tr>
640   <tr><td>Status</td><td>0xA00A</td></tr>
641   <tr><td>WWW-Authenticate</td><td>0xA00B</td></tr>
642 </table>
643
644 </p>
645
646 <p> 
647   After the code or the string header name, the header value is immediately
648   encoded.
649 </p>
650
651 </subsection>
652
653 <subsection name="End Response">
654 <p>
655   Signals the end of this request-handling cycle.  If the
656   <code>reuse</code> flag is true (==1), this TCP connection can now be used to
657   handle new incoming requests.  If <code>reuse</code> is false (anything
658   other than 1 in the actual C code), the connection should be closed.
659 </p>
660 </subsection>
661
662 <subsection name="Get Body Chunk">
663 <p>
664   The container asks for more data from the request (If the body was
665   too large to fit in the first packet sent over or when the request is
666   chuncked).
667   The server will send a body packet back with an amount of data which is
668   the minimum of the <code>request_length</code>,
669   the maximum send body size (8186 (8 Kbytes - 6)), and the
670   number of bytes actually left to send from the request body.
671 <br/>
672   If there is no more data in the body (i.e. the servlet container is
673   trying to read past the end of the body), the server will send back an
674   "empty" packet, which is a body packet with a payload length of 0.
675   (0x12,0x34,0x00,0x00)
676 </p>
677 </subsection>
678 </section>
679
680 <section name="Questions I Have">
681
682 <p> What happens if the request headers > max packet size?  There is no
683 provision to send a second packet of request headers in case there are more
684 than 8K (I think this is correctly handled for response headers, though I'm
685 not certain).  I don't know if there is a way to get more than 8K worth of
686 data into that initial set of request headers, but I'll bet there is
687 (combine long cookies with long ssl information and a lot of environment
688 variables, and you should hit 8K easily).  I think the connector would just
689 fail before trying to send any headers in this case, but I'm not certain.</p>
690
691 <p> What about authentication?  There doesn't seem to be any authentication
692 of the connection between the web server and the container.  This strikes
693 me as potentially dangerous.</p>
694
695 </section>
696
697 </body>
698 </document>