📄 mod_proxy_ajp.html
字号:
codes.</p>
<h3>Method</h3>
<p>The HTTP method, encoded as a single byte:</p>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<tr><td>Command Name</td><td>Code</td></tr>
<tr><td>OPTIONS</td><td>1</td></tr>
<tr><td>GET</td><td>2</td></tr>
<tr><td>HEAD</td><td>3</td></tr>
<tr><td>POST</td><td>4</td></tr>
<tr><td>PUT</td><td>5</td></tr>
<tr><td>DELETE</td><td>6</td></tr>
<tr><td>TRACE</td><td>7</td></tr>
<tr><td>PROPFIND</td><td>8</td></tr>
<tr><td>PROPPATCH</td><td>9</td></tr>
<tr><td>MKCOL</td><td>10</td></tr>
<tr><td>COPY</td><td>11</td></tr>
<tr><td>MOVE</td><td>12</td></tr>
<tr><td>LOCK</td><td>13</td></tr>
<tr><td>UNLOCK</td><td>14</td></tr>
<tr><td>ACL</td><td>15</td></tr>
<tr><td>REPORT</td><td>16</td></tr>
<tr><td>VERSION-CONTROL</td><td>17</td></tr>
<tr><td>CHECKIN</td><td>18</td></tr>
<tr><td>CHECKOUT</td><td>19</td></tr>
<tr><td>UNCHECKOUT</td><td>20</td></tr>
<tr><td>SEARCH</td><td>21</td></tr>
<tr><td>MKWORKSPACE</td><td>22</td></tr>
<tr><td>UPDATE</td><td>23</td></tr>
<tr><td>LABEL</td><td>24</td></tr>
<tr><td>MERGE</td><td>25</td></tr>
<tr><td>BASELINE_CONTROL</td><td>26</td></tr>
<tr><td>MKACTIVITY</td><td>27</td></tr>
</table>
<p>Later version of ajp13, will transport
additional methods, even if they are not in this list.</p>
<h3>protocol, req_uri, remote_addr, remote_host, server_name,
server_port, is_ssl</h3>
<p>These are all fairly self-explanatory. Each of these is required, and
will be sent for every request.</p>
<h3>Headers</h3>
<p>The structure of <code>request_headers</code> is the following:
First, the number of headers <code>num_headers</code> is encoded.
Then, a series of header name <code>req_header_name</code> / value
<code>req_header_value</code> pairs follows.
Common header names are encoded as integers,
to save space. If the header name is not in the list of basic headers,
it is encoded normally (as a string, with prefixed length). The list of
common headers <code>sc_req_header_name</code>and their codes
is as follows (all are case-sensitive):</p>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<tr><td>Name</td><td>Code value</td><td>Code name</td></tr>
<tr><td>accept</td><td>0xA001</td><td>SC_REQ_ACCEPT</td></tr>
<tr><td>accept-charset</td><td>0xA002</td><td>SC_REQ_ACCEPT_CHARSET
</td></tr>
<tr><td>accept-encoding</td><td>0xA003</td><td>SC_REQ_ACCEPT_ENCODING
</td></tr>
<tr><td>accept-language</td><td>0xA004</td><td>SC_REQ_ACCEPT_LANGUAGE
</td></tr>
<tr><td>authorization</td><td>0xA005</td><td>SC_REQ_AUTHORIZATION</td></tr>
<tr><td>connection</td><td>0xA006</td><td>SC_REQ_CONNECTION</td></tr>
<tr><td>content-type</td><td>0xA007</td><td>SC_REQ_CONTENT_TYPE</td></tr>
<tr><td>content-length</td><td>0xA008</td><td>SC_REQ_CONTENT_LENGTH</td></tr>
<tr><td>cookie</td><td>0xA009</td><td>SC_REQ_COOKIE</td></tr>
<tr><td>cookie2</td><td>0xA00A</td><td>SC_REQ_COOKIE2</td></tr>
<tr><td>host</td><td>0xA00B</td><td>SC_REQ_HOST</td></tr>
<tr><td>pragma</td><td>0xA00C</td><td>SC_REQ_PRAGMA</td></tr>
<tr><td>referer</td><td>0xA00D</td><td>SC_REQ_REFERER</td></tr>
<tr><td>user-agent</td><td>0xA00E</td><td>SC_REQ_USER_AGENT</td></tr>
</table>
<p>The Java code that reads this grabs the first two-byte integer and if
it sees an <code>'0xA0'</code> in the most significant
byte, it uses the integer in the second byte as an index into an array of
header names. If the first byte is not <code>0xA0</code>, it assumes that
the two-byte integer is the length of a string, which is then read in.</p>
<p>This works on the assumption that no header names will have length
greater than <code>0x9999 (==0xA000 - 1)</code>, which is perfectly
reasonable, though somewhat arbitrary.</p>
<div class="note"><h3>注意:</h3>
The <code>content-length</code> header is extremely
important. If it is present and non-zero, the container assumes that
the request has a body (a POST request, for example), and immediately
reads a separate packet off the input stream to get that body.
</div>
<h3>Attributes</h3>
<p>The attributes prefixed with a <code>?</code>
(e.g. <code>?context</code>) are all optional. For each, there is a
single byte code to indicate the type of attribute, and then a string to
give its value. They can be sent in any order (thogh the C code always
sends them in the order listed below). A special terminating code is
sent to signal the end of the list of optional attributes. The list of
byte codes is:</p>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<tr><td>Information</td><td>Code Value</td><td>Note</td></tr>
<tr><td>?context</td><td>0x01</td><td>Not currently implemented
</td></tr>
<tr><td>?servlet_path</td><td>0x02</td><td>Not currently implemented
</td></tr>
<tr><td>?remote_user</td><td>0x03</td><td /></tr>
<tr><td>?auth_type</td><td>0x04</td><td /></tr>
<tr><td>?query_string</td><td>0x05</td><td /></tr>
<tr><td>?jvm_route</td><td>0x06</td><td /></tr>
<tr><td>?ssl_cert</td><td>0x07</td><td /></tr>
<tr><td>?ssl_cipher</td><td>0x08</td><td /></tr>
<tr><td>?ssl_session</td><td>0x09</td><td /></tr>
<tr><td>?req_attribute</td><td>0x0A</td><td>Name (the name of the
attribute follows)</td></tr>
<tr><td>?ssl_key_size</td><td>0x0B</td><td /></tr>
<tr><td>are_done</td><td>0xFF</td><td>request_terminator</td></tr>
</table>
<p><code>context</code>和<code>servlet_path</code> are not
currently set by the C code, and most of the Java code completely ignores
whatever is sent over for those fields (and some of it will actually break
if a string is sent along after one of those codes). I don't know if this
is a bug or an unimplemented feature or just vestigial code, but it's
missing from both sides of the connection.</p>
<p><code>remote_user</code>和<code>auth_type</code> presumably
refer to HTTP-level authentication, and communicate the remote user's
username and the type of authentication used to establish their identity
(e.g. Basic, Digest).</p>
<p><code>query_string</code>, <code>ssl_cert</code>, <code>ssl_cipher</code>, and <code>ssl_session</code> refer to the
corresponding pieces of HTTP and HTTPS.</p>
<p><code>jvm_route</code>, is used to support sticky
sessions -- associating a user's sesson with a particular Tomcat instance
in the presence of multiple, load-balancing servers.</p>
<p>Beyond this list of basic attributes, any number of other attributes
can be sent via the <code>req_attribute</code> code <code>0x0A</code>.
A pair of strings to represent the attribute name and value are sent
immediately after each instance of that code. Environment values are passed
in via this method.</p>
<p>Finally, after all the attributes have been sent, the attribute
terminator, <code>0xFF</code>, is sent. This signals both the end of the
list of attributes and also then end of the Request Packet.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="resppacketstruct" id="resppacketstruct">Response Packet Structure</a></h2>
<p>for messages which the container can send back to the server.</p>
<div class="example"><pre>
AJP13_SEND_BODY_CHUNK :=
prefix_code 3
chunk_length (integer)
chunk *(byte)
AJP13_SEND_HEADERS :=
prefix_code 4
http_status_code (integer)
http_status_msg (string)
num_headers (integer)
response_headers *(res_header_name header_value)
res_header_name :=
sc_res_header_name | (string) [see below for how this is parsed]
sc_res_header_name := 0xA0 (byte)
header_value := (string)
AJP13_END_RESPONSE :=
prefix_code 5
reuse (boolean)
AJP13_GET_BODY_CHUNK :=
prefix_code 6
requested_length (integer)
</pre></div>
<h3>Details:</h3>
<h3>Send Body Chunk</h3>
<p>The chunk is basically binary data, and is sent directly back to the
browser.</p>
<h3>Send Headers</h3>
<p>The status code and message are the usual HTTP things
(e.g. <code>200</code>和<code>OK</code>). The response header names are
encoded the same way the request header names are. See header_encoding above
for details about how the the codes are distinguished from the strings.<br />
The codes for common headers are:</p>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<tr><td>Name</td><td>Code value</td></tr>
<tr><td>Content-Type</td><td>0xA001</td></tr>
<tr><td>Content-Language</td><td>0xA002</td></tr>
<tr><td>Content-Length</td><td>0xA003</td></tr>
<tr><td>Date</td><td>0xA004</td></tr>
<tr><td>Last-Modified</td><td>0xA005</td></tr>
<tr><td>Location</td><td>0xA006</td></tr>
<tr><td>Set-Cookie</td><td>0xA007</td></tr>
<tr><td>Set-Cookie2</td><td>0xA008</td></tr>
<tr><td>Servlet-Engine</td><td>0xA009</td></tr>
<tr><td>Status</td><td>0xA00A</td></tr>
<tr><td>WWW-Authenticate</td><td>0xA00B</td></tr>
</table>
<p> After the code or the string header name, the header value is
immediately encoded.</p>
<h3>End Response</h3>
<p>Signals the end of this request-handling cycle. If the
<code>reuse</code> flag is true <code>(==1)</code>, this TCP connection can
now be used to handle new incoming requests. If <code>reuse</code> is false
(anything other than 1 in the actual C code), the connection should
be closed.</p>
<h3>Get Body Chunk</h3>
<p>The container asks for more data from the request (If the body was
too large to fit in the first packet sent over or when the request is
chuncked). The server will send a body packet back with an amount of data
which is the minimum of the <code>request_length</code>, the maximum send
body size <code>(8186 (8 Kbytes - 6))</code>, and the number of bytes
actually left to send from the request body.<br />
If there is no more data in the body (i.e. the servlet container is
trying to read past the end of the body), the server will send back an
<em>empty</em> packet, which is a body packet with a payload length of 0.
<code>(0x12,0x34,0x00,0x00)</code></p>
</div>
</div>
<div id="footer">
<p class="apache">本文允许自由使用、分发、转载,但必须保留译者署名;详见:<a href="../translator_announcement.html#announcement">译者声明</a>。</p>
<p class="menu"><a href="../mod/index.html">模块索引</a> | <a href="../mod/directives.html">指令索引</a> | <a href="../faq/index.html">常见问题</a> | <a href="../glossary.html">词汇表</a> | <a href="../sitemap.html">站点导航</a></p></div>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -