Merge branch 'jetty-http2' into refset

This commit is contained in:
Greg Wilkins 2014-07-31 11:58:30 +10:00
commit a14b2be0e6
12 changed files with 284 additions and 114 deletions

View File

@ -49,6 +49,36 @@ public class HttpTransportOverFCGI implements HttpTransport
@Override
public void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, Callback callback)
{
if (info!=null)
commit(info,content,lastContent,callback);
else
{
if (head)
{
if (lastContent)
{
Generator.Result result = generateResponseContent(BufferUtil.EMPTY_BUFFER, true, callback);
flusher.flush(result);
}
else
{
// Skip content generation
callback.succeeded();
}
}
else
{
Generator.Result result = generateResponseContent(content, lastContent, callback);
flusher.flush(result);
}
if (lastContent && shutdown)
flusher.shutdown();
}
}
private void commit(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, Callback callback)
{
boolean head = this.head = info.isHead();
boolean shutdown = this.shutdown = info.getHttpFields().contains(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString());
@ -78,32 +108,6 @@ public class HttpTransportOverFCGI implements HttpTransport
flusher.shutdown();
}
@Override
public void send(ByteBuffer content, boolean lastContent, Callback callback)
{
if (head)
{
if (lastContent)
{
Generator.Result result = generateResponseContent(BufferUtil.EMPTY_BUFFER, true, callback);
flusher.flush(result);
}
else
{
// Skip content generation
callback.succeeded();
}
}
else
{
Generator.Result result = generateResponseContent(content, lastContent, callback);
flusher.flush(result);
}
if (lastContent && shutdown)
flusher.shutdown();
}
protected Generator.Result generateResponseHeaders(HttpGenerator.ResponseInfo info, Callback callback)
{
return generator.generateResponseHeaders(request, info.getStatus(), info.getReason(), info.getHttpFields(), callback);

View File

@ -29,10 +29,12 @@ package org.eclipse.jetty.http;
* <th>Enum</th>
* <th>Code</th>
* <th>Message</th>
* <th>
* <th>
* <a href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a></th>
* <th>
* <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - HTTP/1.1 Semantics and Content</a></th>
* <th>
* <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a></th>
* <a href="http://tools.ietf.org/html/rfc7238">RFC 7238 - HTTP/1.1 Permanent Redirect</a></th>
* <th>
* <a href="http://tools.ietf.org/html/rfc2518">RFC 2518 - WEBDAV</a></th>
* </tr>
@ -48,7 +50,7 @@ package org.eclipse.jetty.http;
* <td>Continue</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.1.1">Sec. 10.1.1</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.2.1">Sec. 6.2.1</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -57,7 +59,7 @@ package org.eclipse.jetty.http;
* <td>Switching Protocols</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.1.2">Sec. 10.1.2</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.2.2">Sec. 6.2.2</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -82,7 +84,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.2.1">Sec. 10.2.1</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.3.1">Sec. 6.3.1</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -92,7 +94,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.2.2">Sec. 10.2.2</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.3.2">Sec. 6.3.2</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -102,7 +104,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.2.3">Sec. 10.2.3</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.3.3">Sec. 6.3.3</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -111,7 +113,7 @@ package org.eclipse.jetty.http;
* <td>Non Authoritative Information</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.2.4">Sec. 10.2.4</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.3.4">Sec. 6.3.4</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -121,7 +123,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.2">Sec. 9.2</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.2.5">Sec. 10.2.5</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.3.5">Sec. 6.3.5</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -130,7 +132,7 @@ package org.eclipse.jetty.http;
* <td>Reset Content</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.2.6">Sec. 10.2.6</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.3.6">Sec. 6.3.6</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -139,7 +141,7 @@ package org.eclipse.jetty.http;
* <td>Partial Content</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.2.7">Sec. 10.2.7</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.3.7">Sec. 6.3.7</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -175,7 +177,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.1">Sec. 10.3.1</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.1">Sec. 6.4.1</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -185,7 +187,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.2">Sec. 10.3.2</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.2">Sec. 6.4.2</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -203,7 +205,7 @@ package org.eclipse.jetty.http;
* <td>Found</td>
* <td>(was "<code>302 Moved Temporarily</code>")</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.3">Sec. 10.3.3</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.3">Sec. 6.4.3</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -212,7 +214,7 @@ package org.eclipse.jetty.http;
* <td>See Other</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.4">Sec. 10.3.4</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.4">Sec. 6.4.4</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -222,7 +224,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.3">Sec. 9.3</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.5">Sec. 10.3.5</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.5">Sec. 6.4.5</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -231,7 +233,7 @@ package org.eclipse.jetty.http;
* <td>Use Proxy</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.6">Sec. 10.3.6</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.6">Sec. 6.4.6</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -240,7 +242,7 @@ package org.eclipse.jetty.http;
* <td><em>(Unused)</em></td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.7">Sec. 10.3.7</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.7">Sec. 6.4.7</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -249,7 +251,17 @@ package org.eclipse.jetty.http;
* <td>Temporary Redirect</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.3.8">Sec. 10.3.8</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.4.8">Sec. 6.4.8</a></td>
* <td>&nbsp;</td>
* </tr>
*
* <tr>
* <td>{@link #PERMANENT_REDIRECT_308}</td>
* <td>307</td>
* <td>Permanent Redirect</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc7238">RFC7238</a></td>
* <td>&nbsp;</td>
* </tr>
*
@ -265,7 +277,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.1">Sec. 10.4.1</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.1">Sec. 6.5.1</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -275,7 +287,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.2">Sec. 10.4.2</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.2">Sec. 6.5.2</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -285,7 +297,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.3">Sec. 10.4.3</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.3">Sec. 6.5.3</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -295,7 +307,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.4">Sec. 10.4.4</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.4">Sec. 6.5.4</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -305,7 +317,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.4">Sec. 9.4</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.5">Sec. 10.4.5</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.5">Sec. 6.5.5</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -314,7 +326,7 @@ package org.eclipse.jetty.http;
* <td>Method Not Allowed</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.6">Sec. 10.4.6</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.6">Sec. 6.5.6</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -323,7 +335,7 @@ package org.eclipse.jetty.http;
* <td>Not Acceptable</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.7">Sec. 10.4.7</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.7">Sec. 6.5.7</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -332,7 +344,7 @@ package org.eclipse.jetty.http;
* <td>Proxy Authentication Required</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.8">Sec. 10.4.8</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.8">Sec. 6.5.8</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -341,7 +353,7 @@ package org.eclipse.jetty.http;
* <td>Request Timeout</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.9">Sec. 10.4.9</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.5.9">Sec. 6.5.9</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -350,7 +362,7 @@ package org.eclipse.jetty.http;
* <td>Conflict</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.10">Sec. 10.4.10</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.10">Sec. 10.4.10</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -360,7 +372,7 @@ package org.eclipse.jetty.http;
* <td>Gone</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.11">Sec. 10.4.11</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.11">Sec. 10.4.11</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -370,7 +382,7 @@ package org.eclipse.jetty.http;
* <td>Length Required</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.12">Sec. 10.4.12</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.12">Sec. 10.4.12</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -380,7 +392,7 @@ package org.eclipse.jetty.http;
* <td>Precondition Failed</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.13">Sec. 10.4.13</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.13">Sec. 10.4.13</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -390,7 +402,7 @@ package org.eclipse.jetty.http;
* <td>Request Entity Too Large</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.14">Sec. 10.4.14</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.14">Sec. 10.4.14</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -400,7 +412,7 @@ package org.eclipse.jetty.http;
* <td>Request-URI Too Long</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.15">Sec. 10.4.15</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.15">Sec. 10.4.15</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -410,7 +422,7 @@ package org.eclipse.jetty.http;
* <td>Unsupported Media Type</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.16">Sec. 10.4.16</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.16">Sec. 10.4.16</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -420,7 +432,7 @@ package org.eclipse.jetty.http;
* <td>Requested Range Not Satisfiable</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.17">Sec. 10.4.17</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.17">Sec. 10.4.17</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -430,7 +442,7 @@ package org.eclipse.jetty.http;
* <td>Expectation Failed</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.4.18">Sec. 10.4.18</a>
* <a href="http://tools.ietf.org/html/rfc7231#section-10.4.18">Sec. 10.4.18</a>
* </td>
* <td>&nbsp;</td>
* </tr>
@ -537,7 +549,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.5.1">Sec. 10.5.1</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.6.1">Sec. 6.6.1</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -547,7 +559,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.5.2">Sec. 10.5.2</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.6.2">Sec. 6.6.2</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -557,7 +569,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.5.3">Sec. 10.5.3</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.6.3">Sec. 6.6.3</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -567,7 +579,7 @@ package org.eclipse.jetty.http;
* <td>
* <a href="http://tools.ietf.org/html/rfc1945#section-9.5">Sec. 9.5</a></td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.5.4">Sec. 10.5.4</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.6.4">Sec. 6.6.4</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -576,7 +588,7 @@ package org.eclipse.jetty.http;
* <td>Gateway Timeout</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.5.5">Sec. 10.5.5</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.6.5">Sec. 6.6.5</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -585,7 +597,7 @@ package org.eclipse.jetty.http;
* <td>HTTP Version Not Supported</td>
* <td>&nbsp;</td>
* <td>
* <a href="http://tools.ietf.org/html/rfc2616#section-10.5.6">Sec. 10.5.6</a></td>
* <a href="http://tools.ietf.org/html/rfc7231#section-6.6.6">Sec. 6.6.6</a></td>
* <td>&nbsp;</td>
* </tr>
* <tr>
@ -633,6 +645,7 @@ public class HttpStatus
public final static int NOT_MODIFIED_304 = 304;
public final static int USE_PROXY_305 = 305;
public final static int TEMPORARY_REDIRECT_307 = 307;
public final static int PERMANENT_REDIRECT_308 = 308;
public final static int BAD_REQUEST_400 = 400;
public final static int UNAUTHORIZED_401 = 401;
@ -683,7 +696,7 @@ public class HttpStatus
/*
* --------------------------------------------------------------------
* Informational messages in 1xx series. As defined by ... RFC 1945 -
* HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
* HTTP/1.0 RFC 7231 - HTTP/1.1 RFC 2518 - WebDAV
*/
/** <code>100 Continue</code> */
@ -696,7 +709,7 @@ public class HttpStatus
/*
* --------------------------------------------------------------------
* Success messages in 2xx series. As defined by ... RFC 1945 - HTTP/1.0
* RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
* RFC 7231 - HTTP/1.1 RFC 2518 - WebDAV
*/
/** <code>200 OK</code> */
@ -719,7 +732,7 @@ public class HttpStatus
/*
* --------------------------------------------------------------------
* Redirection messages in 3xx series. As defined by ... RFC 1945 -
* HTTP/1.0 RFC 2616 - HTTP/1.1
* HTTP/1.0 RFC 7231 - HTTP/1.1
*/
/** <code>300 Mutliple Choices</code> */
@ -738,11 +751,13 @@ public class HttpStatus
USE_PROXY(USE_PROXY_305, "Use Proxy"),
/** <code>307 Temporary Redirect</code> */
TEMPORARY_REDIRECT(TEMPORARY_REDIRECT_307, "Temporary Redirect"),
/** <code>308 Permanent Redirect</code> */
PERMANET_REDIRECT(PERMANENT_REDIRECT_308, "Permanent Redirect"),
/*
* --------------------------------------------------------------------
* Client Error messages in 4xx series. As defined by ... RFC 1945 -
* HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
* HTTP/1.0 RFC 7231 - HTTP/1.1 RFC 2518 - WebDAV
*/
/** <code>400 Bad Request</code> */
@ -791,7 +806,7 @@ public class HttpStatus
/*
* --------------------------------------------------------------------
* Server Error messages in 5xx series. As defined by ... RFC 1945 -
* HTTP/1.0 RFC 2616 - HTTP/1.1 RFC 2518 - WebDAV
* HTTP/1.0 RFC 7231 - HTTP/1.1 RFC 2518 - WebDAV
*/
/** <code>500 Server Error</code> */
@ -844,7 +859,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Informational</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
* and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
* and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 -
* HTTP/1.1</a>.
*
* @return true if within range of codes that belongs to
@ -859,7 +874,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Success</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
* and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
* and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 -
* HTTP/1.1</a>.
*
* @return true if within range of codes that belongs to
@ -874,7 +889,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Redirection</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
* and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
* and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 -
* HTTP/1.1</a>.
*
* @return true if within range of codes that belongs to
@ -889,7 +904,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Client Error</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
* and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
* and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 -
* HTTP/1.1</a>.
*
* @return true if within range of codes that belongs to
@ -904,7 +919,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Server Error</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>,
* and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 -
* and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 -
* HTTP/1.1</a>.
*
* @return true if within range of codes that belongs to
@ -958,7 +973,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Informational</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
* href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
* href="http://tools.ietf.org/html/rfc7231">RFC 7231 - HTTP/1.1</a>.
*
* @param code
* the code to test.
@ -974,7 +989,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Success</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
* href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
* href="http://tools.ietf.org/html/rfc7231">RFC 7231 - HTTP/1.1</a>.
*
* @param code
* the code to test.
@ -990,7 +1005,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Redirection</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
* href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
* href="http://tools.ietf.org/html/rfc7231">RFC 7231 - HTTP/1.1</a>.
*
* @param code
* the code to test.
@ -1006,7 +1021,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Client Error</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
* href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
* href="http://tools.ietf.org/html/rfc7231">RFC 7231 - HTTP/1.1</a>.
*
* @param code
* the code to test.
@ -1022,7 +1037,7 @@ public class HttpStatus
* Simple test against an code to determine if it falls into the
* <code>Server Error</code> message category as defined in the <a
* href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, and <a
* href="http://tools.ietf.org/html/rfc2616">RFC 2616 - HTTP/1.1</a>.
* href="http://tools.ietf.org/html/rfc7231">RFC 7231 - HTTP/1.1</a>.
*
* @param code
* the code to test.

View File

@ -95,6 +95,8 @@ public class HTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnectionF
HttpTransportOverHTTP2 transport = new HttpTransportOverHTTP2((IStream)stream, frame);
HttpInputOverHTTP2 input = new HttpInputOverHTTP2();
// TODO pool HttpChannels per connection - maybe associate with thread?
HttpChannelOverHTTP2 channel = new HttpChannelOverHTTP2(connector, httpConfiguration, endPoint, transport, input, stream);
stream.setAttribute(CHANNEL_ATTRIBUTE, channel);

View File

@ -45,7 +45,7 @@ public class HttpChannelOverHTTP2 extends HttpChannel
private static final HttpField ACCEPT_ENCODING_GZIP = new HttpField(HttpHeader.ACCEPT_ENCODING,"gzip");
private static final HttpField SERVER_VERSION=new HttpField(HttpHeader.SERVER,HttpConfiguration.SERVER_VERSION);
private static final HttpField POWERED_BY=new HttpField(HttpHeader.X_POWERED_BY,HttpConfiguration.SERVER_VERSION);
private final Stream stream;
private final Stream stream; // TODO recycle channel for new Stream?
public HttpChannelOverHTTP2(Connector connector, HttpConfiguration configuration, EndPoint endPoint, HttpTransport transport, HttpInput input, Stream stream)
{

View File

@ -85,9 +85,8 @@ public class HttpTransportOverHTTP2 implements HttpTransport
HeadersFrame frame = new HeadersFrame(stream.getId(), metaData, null, endStream);
stream.headers(frame, callback);
}
@Override
public void send(ByteBuffer content, boolean lastContent, Callback callback)
private void send(ByteBuffer content, boolean lastContent, Callback callback)
{
if (LOG.isDebugEnabled())
{
@ -98,6 +97,7 @@ public class HttpTransportOverHTTP2 implements HttpTransport
stream.data(frame, callback);
}
@Override
public void completed()
{

View File

@ -534,7 +534,7 @@ public class HttpChannel implements Runnable
else if (info==null)
{
// This is a normal write
_transport.send(content, complete, callback);
_transport.send(null,content, complete, callback);
}
else
{

View File

@ -443,13 +443,6 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
_sendCallback.iterate();
}
@Override
public void send(ByteBuffer content, boolean lastContent, Callback callback)
{
_sendCallback.reset(null,content,lastContent,callback);
_sendCallback.iterate();
}
private class SendCallback extends IteratingCallback
{
private ResponseInfo _info;

View File

@ -26,8 +26,6 @@ import org.eclipse.jetty.util.Callback;
public interface HttpTransport
{
void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, Callback callback);
void send(ByteBuffer content, boolean lastContent, Callback callback);
void completed();

View File

@ -149,7 +149,7 @@ public class Request implements HttpServletRequest
private boolean _handled = false;
private boolean _paramsExtracted;
private boolean _requestedSessionIdFromCookie = false;
private volatile Attributes _attributes;
private Attributes _attributes;
private Authentication _authentication;
private String _characterEncoding;
private ContextHandler.Context _context;

View File

@ -90,12 +90,6 @@ public class ResponseTest
{
callback.succeeded();
}
@Override
public void send(ByteBuffer responseBodyContent, boolean lastContent, Callback callback)
{
send(null,responseBodyContent, lastContent, callback);
}
@Override
public void completed()

View File

@ -89,14 +89,6 @@ public class HttpTransportOverSPDY implements HttpTransport
return requestHeaders;
}
@Override
public void send(ByteBuffer responseBodyContent, boolean lastContent, Callback callback)
{
// TODO can this be more efficient?
send(null, responseBodyContent, lastContent, callback);
}
@Override
public void send(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent, final Callback callback)
{
@ -165,7 +157,6 @@ public class HttpTransportOverSPDY implements HttpTransport
}
else if (!lastContent && !hasContent && info == null)
throw new IllegalStateException("not lastContent, no content and no responseInfo!");
}
private void sendReply(HttpGenerator.ResponseInfo info, Callback callback, boolean close)

View File

@ -0,0 +1,173 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.util.thread;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/* ------------------------------------------------------------ */
/** Strategies to execute Producers
*/
public abstract class ExecutionStrategy implements Runnable
{
public interface Producer
{
/**
* Produce a task to run
* @return A task to run or null if we are complete.
*/
Runnable produce();
/**
* Check if there is more to produce. This method may not return valid
* results until {@link #produce()} has been called.
* @return true if this Producer may produce more tasks from {@link #produce()}
*/
boolean isMoreToProduce();
/**
* Called to signal production is completed
*/
void onCompleted();
}
protected final Producer _producer;
protected final Executor _executor;
protected ExecutionStrategy(Producer producer, Executor executor)
{
_producer=producer;
_executor=executor;
}
/* ------------------------------------------------------------ */
/** Simple iterative strategy.
* Iterate over production until complete and execute each task.
*/
public static class Iterative extends ExecutionStrategy
{
public Iterative(Producer producer, Executor executor)
{
super(producer,executor);
}
public void run()
{
try
{
// Iterate until we are complete
loop: while (true)
{
// produce a task
Runnable task=_producer.produce();
// if there is no task, break the loop
if (task==null)
break loop;
// If we are still producing,
if (_producer.isMoreToProduce())
// execute the task
_executor.execute(task);
else
{
// last task so we can run ourselves
task.run();
break loop;
}
}
}
finally
{
_producer.onCompleted();
}
}
}
/* ------------------------------------------------------------ */
/**
* A Strategy that allows threads to run the tasks that they have produced,
* so execution is done with a hot cache (ie threads eat what they kill).
*/
public static class EatWhatYouKill extends ExecutionStrategy
{
private final AtomicInteger _threads = new AtomicInteger(0);
private final AtomicReference<Boolean> _producing = new AtomicReference<Boolean>(Boolean.FALSE);
private volatile boolean _dispatched;
public EatWhatYouKill(Producer producer, Executor executor)
{
super(producer,executor);
}
public void run()
{
_dispatched=false;
// count the dispatched threads
_threads.incrementAndGet();
try
{
boolean complete=false;
loop: while (!complete)
{
// If another thread is already producing,
if (!_producing.compareAndSet(false,true))
// break the loop even if not complete
break loop;
// If we got here, then we are the thread that is producing
Runnable task=null;
try
{
task=_producer.produce();
complete=task==null || _producer.isMoreToProduce();
}
finally
{
_producing.set(false);
}
// then we may need another thread to keep producing
if (!complete && !_dispatched)
{
// Dispatch a thread to continue producing
_dispatched=true;
_executor.execute(this);
}
// If there is a task,
if (task!=null)
// run the task
task.run();
}
}
finally
{
// If we were the last thread, signal completion
if (_threads.decrementAndGet()==0)
_producer.onCompleted();
}
}
}
}