1 <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>The Apache Tomcat Connector - AJP Protocol Reference - AJPv13</title><meta name="author" value="danmil@shore.net"><meta name="email" value="danmil@shore.net"><meta name="author" value="Jean-Frederic Clere"><meta name="email" value="jfrederic.clere@fujitsu-siemens.com"><link href="../style.css" type="text/css" rel="stylesheet"></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="4"><!--PAGE HEADER--><tr><td colspan="2"><!--TOMCAT LOGO--><a href="http://tomcat.apache.org/"><img src="../images/tomcat.gif" align="left" alt="Apache Tomcat" border="0"></a><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="http://www.apache.org/images/asf-logo.gif" align="right" alt="Apache Logo" border="0"></a></td></tr><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><tr><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap="true"><p><strong>Links</strong></p><ul><li><a href="../index.html">Docs Home</a></li></ul><p><strong>Reference Guide</strong></p><ul><li><a href="../reference/workers.html">workers.properties</a></li><li><a href="../reference/uriworkermap.html">uriworkermap.properties</a></li><li><a href="../reference/status.html">Status Worker</a></li><li><a href="../reference/apache.html">Apache HTTP Server</a></li><li><a href="../reference/iis.html">IIS</a></li></ul><p><strong>Generic HowTo</strong></p><ul><li><a href="../generic_howto/quick.html">For the impatient</a></li><li><a href="../generic_howto/workers.html">All about workers</a></li><li><a href="../generic_howto/timeouts.html">Timeouts</a></li><li><a href="../generic_howto/loadbalancers.html">Load Balancing</a></li><li><a href="../generic_howto/proxy.html">Reverse Proxy</a></li></ul><p><strong>Webserver HowTo</strong></p><ul><li><a href="../webserver_howto/apache.html">Apache HTTP Server</a></li><li><a href="../webserver_howto/iis.html">IIS</a></li><li><a href="../webserver_howto/nes.html">Netscape/SunOne/Sun</a></li></ul><p><strong>AJP Protocol Reference</strong></p><ul><li><a href="../ajp/ajpv13a.html">AJPv13</a></li><li><a href="../ajp/ajpv13ext.html">AJPv13 Extension Proposal</a></li></ul><p><strong>Miscellaneous Documentation</strong></p><ul><li><a href="../miscellaneous/faq.html">Frequently asked questions</a></li><li><a href="../miscellaneous/changelog.html">Changelog</a></li><li><a href="http://issues.apache.org/bugzilla/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=Tomcat+Connectors&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">Current Tomcat Connectors bugs</a></li><li><a href="../miscellaneous/doccontrib.html">Contribute documentation</a></li><li><a href="../miscellaneous/jkstatustasks.html">JK Status Ant Tasks</a></li><li><a href="../miscellaneous/reporttools.html">Reporting Tools</a></li><li><a href="http://tomcat.apache.org/connectors-doc-archive/jk2/index.html">Old JK/JK2 documentation</a></li></ul><p><strong>News</strong></p><ul><li><a href="../news/20110701.html">2011</a></li><li><a href="../news/20100101.html">2010</a></li><li><a href="../news/20090301.html">2009</a></li><li><a href="../news/20081001.html">2008</a></li><li><a href="../news/20070301.html">2007</a></li><li><a href="../news/20060101.html">2006</a></li><li><a href="../news/20050101.html">2005</a></li><li><a href="../news/20041100.html">2004</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left"><table border="0" width="100%" cellspacing="4"><tr><td align="left" valign="top"><h1>The Apache Tomcat Connector - AJP Protocol Reference</h1><h2>AJPv13</h2></td><td align="right" valign="top" nowrap="true"><small><a href="printer/ajpv13a.html"><img src="../images/printer.gif" border="0" alt="Printer Friendly Version"><br>print-friendly<br>version
2 </a></small></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Intro"><strong>Intro</strong></a></font></td></tr><tr><td><blockquote>
5 The original document was written by
6 Dan Milstein, <author email="danmil@shore.net">danmil@shore.net</author>
7 on December 2000. The present document is generated out of an xml file
8 to allow a more easy integration in the Tomcat documentation.
13 This describes the Apache JServ Protocol version 1.3 (hereafter
14 <b>ajp13</b>). There is, apparently, no current documentation of how the
15 protocol works. This document is an attempt to remedy that, in order to
16 make life easier for maintainers of JK, and for anyone who wants to
17 port the protocol somewhere (into jakarta 4.x, for example).
20 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="author"><strong>author</strong></a></font></td></tr><tr><td><blockquote>
23 I am not one of the designers of this protocol -- I believe that Gal
24 Shachor was the original designer. Everything in this document is derived
25 from the actual implementation I found in the tomcat 3.x code. I hope it
26 is useful, but I can't make any grand claims to perfect accuracy. I also
27 don't know why certain design decisions were made. Where I was able, I've
28 offered some possible justifications for certain choices, but those are
29 only my guesses. In general, the C code which Shachor wrote is very clean
30 and comprehensible (if almost totally undocumented). I've cleaned up the
31 Java code, and I think it's reasonably readable.
33 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Design Goals"><strong>Design Goals</strong></a></font></td></tr><tr><td><blockquote>
36 According to email from Gal Shachor to the jakarta-dev mailing list,
37 the original goals of <b>JK</b> (and thus <b>ajp13</b>) were to extend
38 <b>mod_jserv</b> and <b>ajp12</b> by (I am only including the goals which
39 relate to communication between the web server and the servlet container):
42 <li> Increasing performance (speed, specifically). </li>
44 <li> Adding support for SSL, so that <b class="code">isSecure()</b> and
45 <b class="code">getScheme()</b> will function correctly within the servlet
46 container. The client certificates and cipher suite will be
47 available to servlets as request attributes. </li>
51 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Overview of the protocol"><strong>Overview of the protocol</strong></a></font></td></tr><tr><td><blockquote>
54 The <b>ajp13</b> protocol is packet-oriented. A binary format was
55 presumably chosen over the more readable plain text for reasons of
56 performance. The web server communicates with the servlet container over
57 TCP connections. To cut down on the expensive process of socket creation,
58 the web server will attempt to maintain persistent TCP connections to the
59 servlet container, and to reuse a connection for multiple request/response
62 Once a connection is assigned to a particular request, it will not be
63 used for any others until the request-handling cycle has terminated. In
64 other words, requests are not multiplexed over connections. This makes
65 for much simpler code at either end of the connection, although it does
66 cause more connections to be open at once.
68 Once the web server has opened a connection to the servlet container,
69 the connection can be in one of the following states:
72 <li> Idle <br> No request is being handled over this connection. </li>
73 <li> Assigned <br> The connecton is handling a specific request.</li>
77 Once a connection is assigned to handle a particular request, the basic
78 request informaton (e.g. HTTP headers, etc) is sent over the connection in
79 a highly condensed form (e.g. common strings are encoded as integers).
80 Details of that format are below in Request Packet Structure. If there is a
81 body to the request (content-length > 0), that is sent in a separate
82 packet immediately after.
84 At this point, the servlet container is presumably ready to start
85 processing the request. As it does so, it can send the
86 following messages back to the web server:
89 <li>SEND_HEADERS <br>Send a set of headers back to the browser.</li>
91 <li>SEND_BODY_CHUNK <br>Send a chunk of body data back to the browser.</li>
93 <li>GET_BODY_CHUNK <br>Get further data from the request if it hasn't all
94 been transferred yet. This is necessary because the packets have a fixed
95 maximum size and arbitrary amounts of data can be included the body of a
96 request (for uploaded files, for example). (Note: this is unrelated to
97 HTTP chunked tranfer).</li>
99 <li>END_RESPONSE <br> Finish the request-handling cycle.</li>
103 Each message is accompanied by a differently formatted packet of data. See
104 Response Packet Structures below for details.
106 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Basic Packet Structure"><strong>Basic Packet Structure</strong></a></font></td></tr><tr><td><blockquote>
109 There is a bit of an XDR heritage to this protocol, but it differs in
110 lots of ways (no 4 byte alignment, for example).
112 Byte order: I am not clear about the endian-ness of the individual
113 bytes. I'm guessing the bytes are little-endian, because that's what XDR
114 specifies, and I'm guessing that sys/socket library is magically making
115 that so (on the C side). If anyone with a better knowledge of socket calls
116 can step in, that would be great.
118 There are four data types in the protocol: bytes, booleans, integers and
123 <dd>A single byte.</dd>
125 <dt><b>Boolean</b></dt>
126 <dd>A single byte, 1 = true, 0 = false. Using other non-zero values as
127 true (i.e. C-style) may work in some places, but it won't in
130 <dt><b>Integer</b></dt>
131 <dd>A number in the range of 0 to 2^16 (32768). Stored in 2 bytes with
132 the high-order byte first.</dd>
134 <dt><b>String</b></dt>
135 <dd>A variable-sized string (length bounded by 2^16). Encoded with the
136 length packed into two bytes first, followed by the string (including the
137 terminating '\0'). Note that the encoded length does <b>not</b> include
138 the trailing '\0' -- it is like <b class="code">strlen</b>. This is a touch
139 confusing on the Java side, which is littered with odd autoincrement
140 statements to skip over these terminators. I believe the reason this was
141 done was to allow the C code to be extra efficient when reading strings
142 which the servlet container is sending back -- with the terminating \0
143 character, the C code can pass around references into a single buffer,
144 without copying. If the \0 was missing, the C code would have to copy
145 things out in order to get its notion of a string. Note a size of -1
146 (65535) indicates a null string and no data follow the length in this
151 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Packet Size"><strong>Packet Size</strong></a></font></td></tr><tr><td><blockquote>
153 According to much of the code, the max packet
154 size is 8 * 1024 bytes (8K). The actual length of the packet is encoded in the
157 </blockquote></td></tr></table>
159 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Packet Headers"><strong>Packet Headers</strong></a></font></td></tr><tr><td><blockquote>
161 Packets sent from the server to the container begin with
162 <b class="code">0x1234</b>. Packets sent from the container to the server begin
163 with <b class="code">AB</b> (that's the ASCII code for A followed by the ASCII
164 code for B). After those first two bytes, there is an integer (encoded as
165 above) with the length of the payload. Although this might suggest that
166 the maximum payload could be as large as 2^16, in fact, the code sets the
172 <th colspan="6">Packet Format (Server->Container)</th>
188 <td colspan="2">Data Length (n)</td>
195 <th colspan="6"><b>Packet Format (Container->Server)</b></th>
211 <td colspan="2">Data Length (n)</td>
217 <A NAME="prefix-codes"></A> For most packets, the first byte of the
218 payload encodes the type of message. The exception is for request body
219 packets sent from the server to the container -- they are sent with a
220 standard packet header (0x1234 and then length of the packet), but without
221 any prefix code after that (this seems like a mistake to me).
223 The web server can send the following messages to the servlet container:
228 <th>Type of Packet</th>
233 <td>Forward Request</td>
234 <td>Begin the request-processing cycle with the following data</td>
239 <td>The web server asks the container to shut itself down.</td>
244 <td>The web server asks the container to take control (secure login phase).</td>
249 <td>The web server asks the container to respond quickly with a CPong.</td>
254 <td>Size (2 bytes) and corresponding body data.</td>
260 basic security, the container will only actually do the <b class="code">Shutdown</b> if the
261 request comes from the same machine on which it's hosted.
264 The first <b class="code">Data</b> packet is send immediatly after the <b class="code">Forward Request</b> by the web server.
267 <p>The servlet container can send the following types of messages to the web
272 <th>Type of Packet</th>
277 <td>Send Body Chunk</td>
278 <td>Send a chunk of the body from the servlet container to the web
279 server (and presumably, onto the browser). </td>
283 <td>Send Headers</td>
284 <td>Send the response headers from the servlet container to the web
285 server (and presumably, onto the browser).</td>
289 <td>End Response</td>
290 <td>Marks the end of the response (and thus the request-handling cycle).</td>
294 <td>Get Body Chunk</td>
295 <td>Get further data from the request if it hasn't all been transferred
301 <td>The reply to a CPing request</td>
306 Each of the above messages has a different internal structure, detailed below.
308 </blockquote></td></tr></table>
309 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Request Packet Structure"><strong>Request Packet Structure</strong></a></font></td></tr><tr><td><blockquote>
312 For messages from the server to the container of type "Forward Request":
314 <div class="example"><pre>
315 AJP13_FORWARD_REQUEST :=
316 prefix_code (byte) 0x02 = JK_AJP13_FORWARD_REQUEST
323 server_port (integer)
325 num_headers (integer)
326 request_headers *(req_header_name req_header_value)
327 attributes *(attribut_name attribute_value)
328 request_terminator (byte) OxFF
331 The <b class="code">request_headers</b> have the following structure:
333 <div class="example"><pre>
335 sc_req_header_name | (string) [see below for how this is parsed]
337 sc_req_header_name := 0xA0xx (integer)
339 req_header_value := (string)
343 The <b class="code">attributes</b> are optional and have the following structure:
345 <div class="example"><pre>
346 attribute_name := sc_a_name | (sc_a_req_attribute string)
348 attribute_value := (string)
352 Not that the all-important header is "content-length', because it
353 determines whether or not the container looks for another packet
356 Detailed description of the elements of Forward Request.
358 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="request_prefix"><strong>request_prefix</strong></a></font></td></tr><tr><td><blockquote>
360 For all requests, this will be 2.
361 See above for details on other <A HREF="#prefix-codes">prefix codes</A>.
363 </blockquote></td></tr></table>
365 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="method"><strong>method</strong></a></font></td></tr><tr><td><blockquote>
367 The HTTP method, encoded as a single byte:
372 <tr><th>Command Name</th><th>Code</th></tr>
373 <tr><td>OPTIONS</td><td>1</td></tr>
374 <tr><td>GET</td><td>2</td></tr>
375 <tr><td>HEAD</td><td>3</td></tr>
376 <tr><td>POST</td><td>4</td></tr>
377 <tr><td>PUT</td><td>5</td></tr>
378 <tr><td>DELETE</td><td>6</td></tr>
379 <tr><td>TRACE</td><td>7</td></tr>
380 <tr><td>PROPFIND</td><td>8</td></tr>
381 <tr><td>PROPPATCH</td><td>9</td></tr>
382 <tr><td>MKCOL</td><td>10</td></tr>
383 <tr><td>COPY</td><td>11</td></tr>
384 <tr><td>MOVE</td><td>12</td></tr>
385 <tr><td>LOCK</td><td>13</td></tr>
386 <tr><td>UNLOCK</td><td>14</td></tr>
387 <tr><td>ACL</td><td>15</td></tr>
388 <tr><td>REPORT</td><td>16</td></tr>
389 <tr><td>VERSION-CONTROL</td><td>17</td></tr>
390 <tr><td>CHECKIN</td><td>18</td></tr>
391 <tr><td>CHECKOUT</td><td>19</td></tr>
392 <tr><td>UNCHECKOUT</td><td>20</td></tr>
393 <tr><td>SEARCH</td><td>21</td></tr>
394 <tr><td>MKWORKSPACE</td><td>22</td></tr>
395 <tr><td>UPDATE</td><td>23</td></tr>
396 <tr><td>LABEL</td><td>24</td></tr>
397 <tr><td>MERGE</td><td>25</td></tr>
398 <tr><td>BASELINE_CONTROL</td><td>26</td></tr>
399 <tr><td>MKACTIVITY</td><td>27</td></tr>
403 <p>Later version of ajp13, when used with mod_jk2, will transport
404 additional methods, even if they are not in this list.
407 </blockquote></td></tr></table>
409 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="protocol, req_uri, remote_addr, remote_host, server_name, server_port, is_ssl"><strong>protocol, req_uri, remote_addr, remote_host, server_name, server_port, is_ssl</strong></a></font></td></tr><tr><td><blockquote>
411 These are all fairly self-explanatory. Each of these is required, and
412 will be sent for every request.
414 </blockquote></td></tr></table>
416 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Headers"><strong>Headers</strong></a></font></td></tr><tr><td><blockquote>
418 The structure of <b class="code">request_headers</b> is the following:
419 First, the number of headers <b class="code">num_headers</b> is encoded.
420 Then, a series of header name <b class="code">req_header_name</b> / value
421 <b class="code">req_header_value</b> pairs follows.
422 Common header names are encoded as integers,
423 to save space. If the header name is not in the list of basic headers,
424 it is encoded normally (as a string, with prefixed length). The list of
425 common headers <b class="code">sc_req_header_name</b>and their codes
426 is as follows (all are case-sensitive):
429 <tr><th>Name</th><th>Code value</th><th>Code name</th></tr>
430 <tr><td>accept</td><td>0xA001</td><td>SC_REQ_ACCEPT</td></tr>
431 <tr><td>accept-charset</td><td>0xA002</td><td>SC_REQ_ACCEPT_CHARSET</td></tr>
432 <tr><td>accept-encoding</td><td>0xA003</td><td>SC_REQ_ACCEPT_ENCODING</td></tr>
433 <tr><td>accept-language</td><td>0xA004</td><td>SC_REQ_ACCEPT_LANGUAGE</td></tr>
434 <tr><td>authorization</td><td>0xA005</td><td>SC_REQ_AUTHORIZATION</td></tr>
435 <tr><td>connection</td><td>0xA006</td><td>SC_REQ_CONNECTION</td></tr>
436 <tr><td>content-type</td><td>0xA007</td><td>SC_REQ_CONTENT_TYPE</td></tr>
437 <tr><td>content-length</td><td>0xA008</td><td>SC_REQ_CONTENT_LENGTH</td></tr>
438 <tr><td>cookie</td><td>0xA009</td><td>SC_REQ_COOKIE</td></tr>
439 <tr><td>cookie2</td><td>0xA00A</td><td>SC_REQ_COOKIE2</td></tr>
440 <tr><td>host</td><td>0xA00B</td><td>SC_REQ_HOST</td></tr>
441 <tr><td>pragma</td><td>0xA00C</td><td>SC_REQ_PRAGMA</td></tr>
442 <tr><td>referer</td><td>0xA00D</td><td>SC_REQ_REFERER</td></tr>
443 <tr><td>user-agent</td><td>0xA00E</td><td>SC_REQ_USER_AGENT</td></tr>
446 The Java code that reads this grabs the first two-byte integer and if
447 it sees an <b class="code">'0xA0'</b> in the most significant
448 byte, it uses the integer in the second byte as an index into an array of
449 header names. If the first byte is not '0xA0', it assumes that the
450 two-byte integer is the length of a string, which is then read in.
452 This works on the assumption that no header names will have length
453 greater than 0x9999 (==0xA000 - 1), which is perfectly reasonable, though
454 somewhat arbitrary. (If you, like me, started to think about the cookie
455 spec here, and about how long headers can get, fear not -- this limit is
456 on header <b>names</b> not header <b>values</b>. It seems unlikely that
457 unmanageably huge header names will be showing up in the HTTP spec any time
460 <b>Note:</b> The <b class="code">content-length</b> header is extremely
461 important. If it is present and non-zero, the container assumes that
462 the request has a body (a POST request, for example), and immediately
463 reads a separate packet off the input stream to get that body.
465 </blockquote></td></tr></table>
467 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Attributes"><strong>Attributes</strong></a></font></td></tr><tr><td><blockquote>
470 The attributes prefixed with a <b class="code">?</b>
471 (e.g. <b class="code">?context</b>) are all optional. For each, there is a
472 single byte code to indicate the type of attribute, and then a string to
473 give its value. They can be sent in any order (thogh the C code always
474 sends them in the order listed below). A special terminating code is
475 sent to signal the end of the list of optional attributes. The list of
480 <tr><th>Information</th><th>Code Value</th><th>Note</th></tr>
481 <tr><td>?context</td><td>0x01</td><td>Not currently implemented</td></tr>
482 <tr><td>?servlet_path</td><td>0x02</td><td>Not currently implemented</td></tr>
483 <tr><td>?remote_user</td><td>0x03</td><td></td></tr>
484 <tr><td>?auth_type</td><td>0x04</td><td></td></tr>
485 <tr><td>?query_string</td><td>0x05</td><td></td></tr>
486 <tr><td>?route</td><td>0x06</td><td></td></tr>
487 <tr><td>?ssl_cert</td><td>0x07</td><td></td></tr>
488 <tr><td>?ssl_cipher</td><td>0x08</td><td></td></tr>
489 <tr><td>?ssl_session</td><td>0x09</td><td></td></tr>
490 <tr><td>?req_attribute</td><td>0x0A</td><td>Name (the name of the attribut follows)</td></tr>
491 <tr><td>?ssl_key_size</td><td>0x0B</td><td></td></tr>
492 <tr><td>?secret</td><td>0x0C</td><td></td></tr>
493 <tr><td>?stored_method</td><td>0x0D</td><td></td></tr>
494 <tr><td>are_done</td><td>0xFF</td><td>request_terminator</td></tr>
499 The <b class="code">context</b> and <b class="code">servlet_path</b> are not currently
500 set by the C code, and most of the Java code completely ignores whatever
501 is sent over for those fields (and some of it will actually break if a
502 string is sent along after one of those codes). I don't know if this is
503 a bug or an unimplemented feature or just vestigial code, but it's
504 missing from both sides of the connection.
506 The <b class="code">remote_user</b> and <b class="code">auth_type</b> presumably refer
507 to HTTP-level authentication, and communicate the remote user's username
508 and the type of authentication used to establish their identity (e.g. Basic,
509 Digest). I'm not clear on why the password isn't also sent, but I don't
510 know HTTP authentication inside and out.
512 The <b class="code">query_string</b>, <b class="code">ssl_cert</b>,
513 <b class="code">ssl_cipher</b>, and <b class="code">ssl_session</b> refer to the
514 corresponding pieces of HTTP and HTTPS.
516 The <b class="code">route</b>, as I understand it, is used to support sticky
517 sessions -- associating a user's sesson with a particular Tomcat instance
518 in the presence of multiple, load-balancing servers. I don't know the
521 Beyond this list of basic attributes, any number of other attributes can
522 be sent via the <b class="code">req_attribute</b> code (0x0A). A pair of strings
523 to represent the attribute name and value are sent immediately after each
524 instance of that code. Environment values are passed in via this method.
526 Finally, after all the attributes have been sent, the attribute terminator,
527 0xFF, is sent. This signals both the end of the list of attributes and
528 also then end of the Request Packet.
530 </blockquote></td></tr></table>
532 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Response Packet Structure"><strong>Response Packet Structure</strong></a></font></td></tr><tr><td><blockquote>
535 For messages which the container can send back to the server.
537 <div class="example"><pre>
538 AJP13_SEND_BODY_CHUNK :=
540 chunk_length (integer)
544 AJP13_SEND_HEADERS :=
546 http_status_code (integer)
547 http_status_msg (string)
548 num_headers (integer)
549 response_headers *(res_header_name header_value)
552 sc_res_header_name | (string) [see below for how this is parsed]
554 sc_res_header_name := 0xA0 (byte)
556 header_value := (string)
558 AJP13_END_RESPONSE :=
563 AJP13_GET_BODY_CHUNK :=
565 requested_length (integer)
573 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Send Body Chunk"><strong>Send Body Chunk</strong></a></font></td></tr><tr><td><blockquote>
575 The chunk is basically binary data, and is sent directly back to the browser.
577 </blockquote></td></tr></table>
579 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Send Headers"><strong>Send Headers</strong></a></font></td></tr><tr><td><blockquote>
581 The status code and message are the usual HTTP things (e.g. "200" and "OK").
582 The response header names are encoded the same way the request header names are.
583 See <A HREF="#header_encoding">above</A> for details about how the the
584 codes are distinguished from the strings. The codes for common headers are:
589 <tr><th>Name</th><th>Code value</th></tr>
590 <tr><td>Content-Type</td><td>0xA001</td></tr>
591 <tr><td>Content-Language</td><td>0xA002</td></tr>
592 <tr><td>Content-Length</td><td>0xA003</td></tr>
593 <tr><td>Date</td><td>0xA004</td></tr>
594 <tr><td>Last-Modified</td><td>0xA005</td></tr>
595 <tr><td>Location</td><td>0xA006</td></tr>
596 <tr><td>Set-Cookie</td><td>0xA007</td></tr>
597 <tr><td>Set-Cookie2</td><td>0xA008</td></tr>
598 <tr><td>Servlet-Engine</td><td>0xA009</td></tr>
599 <tr><td>Status</td><td>0xA00A</td></tr>
600 <tr><td>WWW-Authenticate</td><td>0xA00B</td></tr>
606 After the code or the string header name, the header value is immediately
610 </blockquote></td></tr></table>
612 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="End Response"><strong>End Response</strong></a></font></td></tr><tr><td><blockquote>
614 Signals the end of this request-handling cycle. If the
615 <b class="code">reuse</b> flag is true (==1), this TCP connection can now be used to
616 handle new incoming requests. If <b class="code">reuse</b> is false (anything
617 other than 1 in the actual C code), the connection should be closed.
619 </blockquote></td></tr></table>
621 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Get Body Chunk"><strong>Get Body Chunk</strong></a></font></td></tr><tr><td><blockquote>
623 The container asks for more data from the request (If the body was
624 too large to fit in the first packet sent over or when the request is
626 The server will send a body packet back with an amount of data which is
627 the minimum of the <b class="code">request_length</b>,
628 the maximum send body size (8186 (8 Kbytes - 6)), and the
629 number of bytes actually left to send from the request body.
631 If there is no more data in the body (i.e. the servlet container is
632 trying to read past the end of the body), the server will send back an
633 "empty" packet, which is a body packet with a payload length of 0.
634 (0x12,0x34,0x00,0x00)
636 </blockquote></td></tr></table>
637 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Questions I Have"><strong>Questions I Have</strong></a></font></td></tr><tr><td><blockquote>
639 <p> What happens if the request headers > max packet size? There is no
640 provision to send a second packet of request headers in case there are more
641 than 8K (I think this is correctly handled for response headers, though I'm
642 not certain). I don't know if there is a way to get more than 8K worth of
643 data into that initial set of request headers, but I'll bet there is
644 (combine long cookies with long ssl information and a lot of environment
645 variables, and you should hit 8K easily). I think the connector would just
646 fail before trying to send any headers in this case, but I'm not certain.</p>
648 <p> What about authentication? There doesn't seem to be any authentication
649 of the connection between the web server and the container. This strikes
650 me as potentially dangerous.</p>
652 </blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
653 Copyright © 1999-2011, Apache Software Foundation
654 </em></font></div></td></tr></table></body></html>