diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index dd5348a46c5..73916c68a55 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -601,7 +601,7 @@ public class HttpParser if (_state==State.URI) { LOG.warn("URI is too large >"+_maxHeaderBytes); - throw new BadMessageException(HttpStatus.REQUEST_URI_TOO_LONG_414); + throw new BadMessageException(HttpStatus.URI_TOO_LONG_414); } else { @@ -609,7 +609,7 @@ public class HttpParser LOG.warn("request is too large >"+_maxHeaderBytes); else LOG.warn("response is too large >"+_maxHeaderBytes); - throw new BadMessageException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413); + throw new BadMessageException(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431); } } @@ -983,7 +983,7 @@ public class HttpParser if (_maxHeaderBytes>0 && ++_headerBytes>_maxHeaderBytes) { LOG.warn("Header is too large >"+_maxHeaderBytes); - throw new BadMessageException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413); + throw new BadMessageException(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431); } switch (_state) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java index 56828895375..18174143a1f 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpStatus.java @@ -20,608 +20,9 @@ package org.eclipse.jetty.http; /** *
- * HttpStatusCode enum class, for status codes based on various HTTP RFCs. (see - * table below) + * Http Status Codes *
- * - *Enum | - *Code | - *Message | - *- * RFC 1945 - HTTP/1.0 | - *- * RFC 7231 - HTTP/1.1 Semantics and Content | - *- * RFC 7238 - HTTP/1.1 Permanent Redirect | - *- * RFC 2518 - WEBDAV | - *
---|---|---|---|---|---|---|
Informational - 1xx |
- * {@link #isInformational(int)} | - *|||||
{@link #CONTINUE_100} | - *100 | - *Continue | - *- * | - * Sec. 6.2.1 | - *- * | |
{@link #SWITCHING_PROTOCOLS_101} | - *101 | - *Switching Protocols | - *- * | - * Sec. 6.2.2 | - *- * | |
{@link #PROCESSING_102} | - *102 | - *Processing | - *- * | - * | - * Sec. 10.1 | - *|
Success - 2xx |
- * {@link #isSuccess(int)} | - *|||||
{@link #OK_200} | - *200 | - *OK | - *- * Sec. 9.2 | - *- * Sec. 6.3.1 | - *- * | |
{@link #CREATED_201} | - *201 | - *Created | - *- * Sec. 9.2 | - *- * Sec. 6.3.2 | - *- * | |
{@link #ACCEPTED_202} | - *202 | - *Accepted | - *- * Sec. 9.2 | - *- * Sec. 6.3.3 | - *- * | |
{@link #NON_AUTHORITATIVE_INFORMATION_203} | - *203 | - *Non Authoritative Information | - *- * | - * Sec. 6.3.4 | - *- * | |
{@link #NO_CONTENT_204} | - *204 | - *No Content | - *- * Sec. 9.2 | - *- * Sec. 6.3.5 | - *- * | |
{@link #RESET_CONTENT_205} | - *205 | - *Reset Content | - *- * | - * Sec. 6.3.6 | - *- * | |
{@link #PARTIAL_CONTENT_206} | - *206 | - *Partial Content | - *- * | - * Sec. 6.3.7 | - *- * | |
{@link #MULTI_STATUS_207} | - *207 | - *Multi-Status | - *- * | - * | - * Sec. 10.2 | - *|
- * | 207 | - *Partial Update OK | - *- * | - * draft/01 | - *- * | |
Redirection - 3xx |
- * {@link #isRedirection(int)} | - *|||||
{@link #MULTIPLE_CHOICES_300} | - *300 | - *Multiple Choices | - *- * Sec. 9.3 | - *- * Sec. 6.4.1 | - *- * | |
{@link #MOVED_PERMANENTLY_301} | - *301 | - *Moved Permanently | - *- * Sec. 9.3 | - *- * Sec. 6.4.2 | - *- * | |
{@link #MOVED_TEMPORARILY_302} | - *302 | - *Moved Temporarily | - *- * Sec. 9.3 | - *(now "302 Found ") |
- * - * | |
{@link #FOUND_302} | - *302 | - *Found | - *(was "302 Moved Temporarily ") |
- * - * Sec. 6.4.3 | - *- * | |
{@link #SEE_OTHER_303} | - *303 | - *See Other | - *- * | - * Sec. 6.4.4 | - *- * | |
{@link #NOT_MODIFIED_304} | - *304 | - *Not Modified | - *- * Sec. 9.3 | - *- * Sec. 6.4.5 | - *- * | |
{@link #USE_PROXY_305} | - *305 | - *Use Proxy | - *- * | - * Sec. 6.4.6 | - *- * | |
- * | 306 | - *(Unused) | - *- * | - * Sec. 6.4.7 | - *- * | |
{@link #TEMPORARY_REDIRECT_307} | - *307 | - *Temporary Redirect | - *- * | - * Sec. 6.4.8 | - *- * | |
{@link #PERMANENT_REDIRECT_308} | - *307 | - *Permanent Redirect | - *- * | - * RFC7238 | - *- * | |
Client Error - 4xx |
- * {@link #isClientError(int)} | - *|||||
{@link #BAD_REQUEST_400} | - *400 | - *Bad Request | - *- * Sec. 9.4 | - *- * Sec. 6.5.1 | - *- * | |
{@link #UNAUTHORIZED_401} | - *401 | - *Unauthorized | - *- * Sec. 9.4 | - *- * Sec. 6.5.2 | - *- * | |
{@link #PAYMENT_REQUIRED_402} | - *402 | - *Payment Required | - *- * Sec. 9.4 | - *- * Sec. 6.5.3 | - *- * | |
{@link #FORBIDDEN_403} | - *403 | - *Forbidden | - *- * Sec. 9.4 | - *- * Sec. 6.5.4 | - *- * | |
{@link #NOT_FOUND_404} | - *404 | - *Not Found | - *- * Sec. 9.4 | - *- * Sec. 6.5.5 | - *- * | |
{@link #METHOD_NOT_ALLOWED_405} | - *405 | - *Method Not Allowed | - *- * | - * Sec. 6.5.6 | - *- * | |
{@link #NOT_ACCEPTABLE_406} | - *406 | - *Not Acceptable | - *- * | - * Sec. 6.5.7 | - *- * | |
{@link #PROXY_AUTHENTICATION_REQUIRED_407} | - *407 | - *Proxy Authentication Required | - *- * | - * Sec. 6.5.8 | - *- * | |
{@link #REQUEST_TIMEOUT_408} | - *408 | - *Request Timeout | - *- * | - * Sec. 6.5.9 | - *- * | |
{@link #CONFLICT_409} | - *409 | - *Conflict | - *- * | - * Sec. 10.4.10 - * | - *- * | |
{@link #GONE_410} | - *410 | - *Gone | - *- * | - * Sec. 10.4.11 - * | - *- * | |
{@link #LENGTH_REQUIRED_411} | - *411 | - *Length Required | - *- * | - * Sec. 10.4.12 - * | - *- * | |
{@link #PRECONDITION_FAILED_412} | - *412 | - *Precondition Failed | - *- * | - * Sec. 10.4.13 - * | - *- * | |
{@link #REQUEST_ENTITY_TOO_LARGE_413} | - *413 | - *Request Entity Too Large | - *- * | - * Sec. 10.4.14 - * | - *- * | |
{@link #REQUEST_URI_TOO_LONG_414} | - *414 | - *Request-URI Too Long | - *- * | - * Sec. 10.4.15 - * | - *- * | |
{@link #UNSUPPORTED_MEDIA_TYPE_415} | - *415 | - *Unsupported Media Type | - *- * | - * Sec. 10.4.16 - * | - *- * | |
{@link #REQUESTED_RANGE_NOT_SATISFIABLE_416} | - *416 | - *Requested Range Not Satisfiable | - *- * | - * Sec. 10.4.17 - * | - *- * | |
{@link #EXPECTATION_FAILED_417} | - *417 | - *Expectation Failed | - *- * | - * Sec. 10.4.18 - * | - *- * | |
- * | 418 | - *Reauthentication Required | - *- * | - * draft/01 | - *- * | |
- * | 418 | - *Unprocessable Entity | - *- * | - * | - * draft/05 | - *|
- * | 419 | - *Proxy Reauthentication Required | - *- * | - * draft/01 | - *- * | |
- * | 419 | - *Insufficient Space on Resource | - *- * | - * | - * draft/05 | - *|
- * | 420 | - *Method Failure | - *- * | - * | - * draft/05 | - *|
- * | 421 | - *(Unused) | - *- * | - * | - * | |
{@link #UNPROCESSABLE_ENTITY_422} | - *422 | - *Unprocessable Entity | - *- * | - * | - * Sec. 10.3 | - *|
{@link #LOCKED_423} | - *423 | - *Locked | - *- * | - * | - * Sec. 10.4 | - *|
{@link #FAILED_DEPENDENCY_424} | - *424 | - *Failed Dependency | - *- * | - * | - * Sec. 10.5 | - *|
Server Error - 5xx |
- * {@link #isServerError(int)} | - *|||||
{@link #INTERNAL_SERVER_ERROR_500} | - *500 | - *Internal Server Error | - *- * Sec. 9.5 | - *- * Sec. 6.6.1 | - *- * | |
{@link #NOT_IMPLEMENTED_501} | - *501 | - *Not Implemented | - *- * Sec. 9.5 | - *- * Sec. 6.6.2 | - *- * | |
{@link #BAD_GATEWAY_502} | - *502 | - *Bad Gateway | - *- * Sec. 9.5 | - *- * Sec. 6.6.3 | - *- * | |
{@link #SERVICE_UNAVAILABLE_503} | - *503 | - *Service Unavailable | - *- * Sec. 9.5 | - *- * Sec. 6.6.4 | - *- * | |
{@link #GATEWAY_TIMEOUT_504} | - *504 | - *Gateway Timeout | - *- * | - * Sec. 6.6.5 | - *- * | |
{@link #HTTP_VERSION_NOT_SUPPORTED_505} | - *505 | - *HTTP Version Not Supported | - *- * | - * Sec. 6.6.6 | - *- * | |
- * | 506 | - *(Unused) | - *- * | - * | - * | |
{@link #INSUFFICIENT_STORAGE_507} | - *507 | - *Insufficient Storage | - *- * | - * | - * Sec. 10.6 | - *
100 Continue
*/
CONTINUE(CONTINUE_100, "Continue"),
- /** 101 Switching Protocols
*/
SWITCHING_PROTOCOLS(SWITCHING_PROTOCOLS_101, "Switching Protocols"),
- /** 102 Processing
*/
PROCESSING(PROCESSING_102, "Processing"),
- /*
- * --------------------------------------------------------------------
- * Success messages in 2xx series. As defined by ... RFC 1945 - HTTP/1.0
- * RFC 7231 - HTTP/1.1 RFC 2518 - WebDAV
- */
- /** 200 OK
*/
OK(OK_200, "OK"),
- /** 201 Created
*/
CREATED(CREATED_201, "Created"),
- /** 202 Accepted
*/
ACCEPTED(ACCEPTED_202, "Accepted"),
- /** 203 Non Authoritative Information
*/
NON_AUTHORITATIVE_INFORMATION(NON_AUTHORITATIVE_INFORMATION_203, "Non Authoritative Information"),
- /** 204 No Content
*/
NO_CONTENT(NO_CONTENT_204, "No Content"),
- /** 205 Reset Content
*/
RESET_CONTENT(RESET_CONTENT_205, "Reset Content"),
- /** 206 Partial Content
*/
PARTIAL_CONTENT(PARTIAL_CONTENT_206, "Partial Content"),
- /** 207 Multi-Status
*/
MULTI_STATUS(MULTI_STATUS_207, "Multi-Status"),
- /*
- * --------------------------------------------------------------------
- * Redirection messages in 3xx series. As defined by ... RFC 1945 -
- * HTTP/1.0 RFC 7231 - HTTP/1.1
- */
-
- /** 300 Mutliple Choices
*/
MULTIPLE_CHOICES(MULTIPLE_CHOICES_300, "Multiple Choices"),
- /** 301 Moved Permanently
*/
MOVED_PERMANENTLY(MOVED_PERMANENTLY_301, "Moved Permanently"),
- /** 302 Moved Temporarily
*/
MOVED_TEMPORARILY(MOVED_TEMPORARILY_302, "Moved Temporarily"),
- /** 302 Found
*/
FOUND(FOUND_302, "Found"),
- /** 303 See Other
*/
SEE_OTHER(SEE_OTHER_303, "See Other"),
- /** 304 Not Modified
*/
NOT_MODIFIED(NOT_MODIFIED_304, "Not Modified"),
- /** 305 Use Proxy
*/
USE_PROXY(USE_PROXY_305, "Use Proxy"),
- /** 307 Temporary Redirect
*/
TEMPORARY_REDIRECT(TEMPORARY_REDIRECT_307, "Temporary Redirect"),
- /** 308 Permanent Redirect
*/
PERMANET_REDIRECT(PERMANENT_REDIRECT_308, "Permanent Redirect"),
- /*
- * --------------------------------------------------------------------
- * Client Error messages in 4xx series. As defined by ... RFC 1945 -
- * HTTP/1.0 RFC 7231 - HTTP/1.1 RFC 2518 - WebDAV
- */
-
- /** 400 Bad Request
*/
BAD_REQUEST(BAD_REQUEST_400, "Bad Request"),
- /** 401 Unauthorized
*/
UNAUTHORIZED(UNAUTHORIZED_401, "Unauthorized"),
- /** 402 Payment Required
*/
PAYMENT_REQUIRED(PAYMENT_REQUIRED_402, "Payment Required"),
- /** 403 Forbidden
*/
FORBIDDEN(FORBIDDEN_403, "Forbidden"),
- /** 404 Not Found
*/
NOT_FOUND(NOT_FOUND_404, "Not Found"),
- /** 405 Method Not Allowed
*/
METHOD_NOT_ALLOWED(METHOD_NOT_ALLOWED_405, "Method Not Allowed"),
- /** 406 Not Acceptable
*/
NOT_ACCEPTABLE(NOT_ACCEPTABLE_406, "Not Acceptable"),
- /** 407 Proxy Authentication Required
*/
PROXY_AUTHENTICATION_REQUIRED(PROXY_AUTHENTICATION_REQUIRED_407, "Proxy Authentication Required"),
- /** 408 Request Timeout
*/
REQUEST_TIMEOUT(REQUEST_TIMEOUT_408, "Request Timeout"),
- /** 409 Conflict
*/
CONFLICT(CONFLICT_409, "Conflict"),
- /** 410 Gone
*/
GONE(GONE_410, "Gone"),
- /** 411 Length Required
*/
LENGTH_REQUIRED(LENGTH_REQUIRED_411, "Length Required"),
- /** 412 Precondition Failed
*/
PRECONDITION_FAILED(PRECONDITION_FAILED_412, "Precondition Failed"),
- /** 413 Request Entity Too Large
*/
- REQUEST_ENTITY_TOO_LARGE(REQUEST_ENTITY_TOO_LARGE_413, "Request Entity Too Large"),
- /** 414 Request-URI Too Long
*/
- REQUEST_URI_TOO_LONG(REQUEST_URI_TOO_LONG_414, "Request-URI Too Long"),
- /** 415 Unsupported Media Type
*/
+ PAYLOAD_TOO_LARGE(PAYLOAD_TOO_LARGE_413, "Payload Too Large"),
+ URI_TOO_LONG(URI_TOO_LONG_414, "URI Too Long"),
UNSUPPORTED_MEDIA_TYPE(UNSUPPORTED_MEDIA_TYPE_415, "Unsupported Media Type"),
- /** 416 Requested Range Not Satisfiable
*/
- REQUESTED_RANGE_NOT_SATISFIABLE(REQUESTED_RANGE_NOT_SATISFIABLE_416, "Requested Range Not Satisfiable"),
- /** 417 Expectation Failed
*/
+ RANGE_NOT_SATISFIABLE(RANGE_NOT_SATISFIABLE_416, "Range Not Satisfiable"),
EXPECTATION_FAILED(EXPECTATION_FAILED_417, "Expectation Failed"),
- /** 421 Misdirected Request(RFC7234)y
*/
+ IM_A_TEAPOT(IM_A_TEAPOT_418, "Im a Teapot"),
+ ENHANCE_YOUR_CALM(ENHANCE_YOUR_CALM_420, "Enhance your Calm"),
MISDIRECTED_REQUEST(MISDIRECTED_REQUEST_421, "Misdirected Request"),
- /** 422 Unprocessable Entity
*/
UNPROCESSABLE_ENTITY(UNPROCESSABLE_ENTITY_422, "Unprocessable Entity"),
- /** 423 Locked
*/
LOCKED(LOCKED_423, "Locked"),
- /** 424 Failed Dependency
*/
FAILED_DEPENDENCY(FAILED_DEPENDENCY_424, "Failed Dependency"),
-
- /** 426 Upgrade Required (RFC7231)
*/
UPGRADE_REQUIRED(UPGRADE_REQUIRED_426, "Upgrade Required"),
-
- /** 428 Precondition Required (RFC6585)
*/
PRECONDITION_REQUIRED(PRECONDITION_REQUIRED_428, "Precondition Required"),
- /** 429 Too Many Requests (RFC6585)
*/
TOO_MANY_REQUESTS(TOO_MANY_REQUESTS_429, "Too Many Requests"),
- /** 431 Request Header Fields Too Large (RFC6585)
*/
REQUEST_HEADER_FIELDS_TOO_LARGE(REQUEST_HEADER_FIELDS_TOO_LARGE_431, "Request Header Fields Too Large"),
-
- /*
- * --------------------------------------------------------------------
- * Server Error messages in 5xx series. As defined by ... RFC 1945 -
- * HTTP/1.0 RFC 7231 - HTTP/1.1 RFC 2518 - WebDAV
- */
+ UNAVAILABLE_FOR_LEGAL_REASONS(UNAVAILABLE_FOR_LEGAL_REASONS_451, "Unavailable for Legal Reason"),
- /** 500 Server Error
*/
INTERNAL_SERVER_ERROR(INTERNAL_SERVER_ERROR_500, "Server Error"),
- /** 501 Not Implemented
*/
NOT_IMPLEMENTED(NOT_IMPLEMENTED_501, "Not Implemented"),
- /** 502 Bad Gateway
*/
BAD_GATEWAY(BAD_GATEWAY_502, "Bad Gateway"),
- /** 503 Service Unavailable
*/
SERVICE_UNAVAILABLE(SERVICE_UNAVAILABLE_503, "Service Unavailable"),
- /** 504 Gateway Timeout
*/
GATEWAY_TIMEOUT(GATEWAY_TIMEOUT_504, "Gateway Timeout"),
- /** 505 HTTP Version Not Supported
*/
HTTP_VERSION_NOT_SUPPORTED(HTTP_VERSION_NOT_SUPPORTED_505, "HTTP Version Not Supported"),
- /** 507 Insufficient Storage
*/
INSUFFICIENT_STORAGE(INSUFFICIENT_STORAGE_507, "Insufficient Storage"),
-
- /** 511 Network Authentication Required (RFC6585)
*/
+ LOOP_DETECTED(LOOP_DETECTED_508, "Loop Detected"),
+ NOT_EXTENDED(NOT_EXTENDED_510, "Not Extended"),
NETWORK_AUTHENTICATION_REQUIRED(NETWORK_AUTHENTICATION_REQUIRED_511, "Network Authentication Required"),
;
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
index d797d316a95..40a19142836 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
@@ -320,7 +320,9 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
}
case SettingsFrame.MAX_HEADER_LIST_SIZE:
{
- // Handled by HTTP2ServerConnectionFactory.HTTPServerSessionListener.
+ if (LOG.isDebugEnabled())
+ LOG.debug("Update max header list size to {}", value);
+ generator.setMaxHeaderListSize(value);
break;
}
default:
diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java
index 961e2de9b8b..c6b2bc6ae67 100644
--- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java
+++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/Generator.java
@@ -84,4 +84,9 @@ public class Generator
{
dataGenerator.generate(lease, frame, maxLength);
}
+
+ public void setMaxHeaderListSize(int value)
+ {
+ hpackEncoder.setMaxHeaderListSize(value);
+ }
}
diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java
index c0564daa9ca..ffb0ee606d6 100644
--- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java
+++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackDecoder.java
@@ -47,7 +47,7 @@ public class HpackDecoder
/**
* @param localMaxDynamicTableSize The maximum allowed size of the local dynamic header field table.
- * @param maxHeaderSize The maximum allowed size of a headers block, expressed as total of all name and value characters.
+ * @param maxHeaderSize The maximum allowed size of a headers block, expressed as total of all name and value characters, plus 32 per field
*/
public HpackDecoder(int localMaxDynamicTableSize, int maxHeaderSize)
{
@@ -73,8 +73,7 @@ public class HpackDecoder
// If the buffer is big, don't even think about decoding it
if (buffer.remaining()>_builder.getMaxSize())
- throw new BadMessageException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413,"Header frame size "+buffer.remaining()+">"+_builder.getMaxSize());
-
+ throw new BadMessageException(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431,"Header frame size "+buffer.remaining()+">"+_builder.getMaxSize());
while(buffer.hasRemaining())
{
@@ -144,7 +143,6 @@ public class HpackDecoder
name_index=NBitInteger.decode(buffer,4);
break;
-
case 4: // 7.2.1
case 5: // 7.2.1
case 6: // 7.2.1
@@ -157,7 +155,6 @@ public class HpackDecoder
throw new IllegalStateException();
}
-
boolean huffmanName=false;
// decode the name
diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java
index 098cec41e20..b56fdb16b77 100644
--- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java
+++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/HpackEncoder.java
@@ -87,25 +87,43 @@ public class HpackEncoder
private final boolean _debug;
private int _remoteMaxDynamicTableSize;
private int _localMaxDynamicTableSize;
+ private int _maxHeaderListSize;
+ private int _size;
public HpackEncoder()
{
- this(4096,4096);
+ this(4096,4096,-1);
}
public HpackEncoder(int localMaxDynamicTableSize)
{
- this(localMaxDynamicTableSize,4096);
+ this(localMaxDynamicTableSize,4096,-1);
}
-
+
public HpackEncoder(int localMaxDynamicTableSize,int remoteMaxDynamicTableSize)
+ {
+ this(localMaxDynamicTableSize,remoteMaxDynamicTableSize,-1);
+ }
+
+ public HpackEncoder(int localMaxDynamicTableSize,int remoteMaxDynamicTableSize, int maxHeaderListSize)
{
_context=new HpackContext(remoteMaxDynamicTableSize);
_remoteMaxDynamicTableSize=remoteMaxDynamicTableSize;
_localMaxDynamicTableSize=localMaxDynamicTableSize;
+ _maxHeaderListSize=maxHeaderListSize;
_debug=LOG.isDebugEnabled();
}
+ public int getMaxHeaderListSize()
+ {
+ return _maxHeaderListSize;
+ }
+
+ public void setMaxHeaderListSize(int maxHeaderListSize)
+ {
+ _maxHeaderListSize = maxHeaderListSize;
+ }
+
public HpackContext getHpackContext()
{
return _context;
@@ -126,6 +144,7 @@ public class HpackEncoder
if (LOG.isDebugEnabled())
LOG.debug(String.format("CtxTbl[%x] encoding",_context.hashCode()));
+ _size=0;
int pos = buffer.position();
// Check the dynamic table sizes!
@@ -144,7 +163,6 @@ public class HpackEncoder
encode(buffer,new HttpField(HttpHeader.C_METHOD,request.getMethod()));
encode(buffer,new HttpField(HttpHeader.C_AUTHORITY,request.getURI().getAuthority()));
encode(buffer,new HttpField(HttpHeader.C_PATH,request.getURI().getPathQuery()));
-
}
else if (metadata.isResponse())
{
@@ -160,6 +178,14 @@ public class HpackEncoder
for (HttpField field : metadata)
encode(buffer,field);
+ // Check size
+ if (_maxHeaderListSize>0 && _size>_maxHeaderListSize)
+ {
+ LOG.warn("Header list size too large {} > {} for {}",_size,_maxHeaderListSize);
+ if (LOG.isDebugEnabled())
+ LOG.debug("metadata={}",metadata);
+ }
+
if (LOG.isDebugEnabled())
LOG.debug(String.format("CtxTbl[%x] encoded %d octets",_context.hashCode(), buffer.position() - pos));
}
@@ -178,6 +204,9 @@ public class HpackEncoder
if (field.getValue()==null)
field = new HttpField(field.getHeader(),field.getName(),"");
+ int field_size = field.getName().length() + field.getValue().length();
+ _size+=field_size+32;
+
final int p=_debug?buffer.position():-1;
String encoding=null;
diff --git a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java
index 4608e8c5f71..fbbec475836 100644
--- a/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java
+++ b/jetty-http2/http2-hpack/src/main/java/org/eclipse/jetty/http2/hpack/MetaDataBuilder.java
@@ -72,9 +72,9 @@ public class MetaDataBuilder
String name = field.getName();
String value = field.getValue();
int field_size = name.length() + (value == null ? 0 : value.length());
- _size+=field_size;
+ _size+=field_size+32;
if (_size>_maxSize)
- throw new BadMessageException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413,"Header size "+_size+">"+_maxSize);
+ throw new BadMessageException(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431,"Header size "+_size+">"+_maxSize);
if (field instanceof StaticTableHttpField)
{
@@ -191,6 +191,6 @@ public class MetaDataBuilder
if (huffman)
length=(length*4)/3;
if ((_size+length)>_maxSize)
- throw new BadMessageException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413,"Header size "+(_size+length)+">"+_maxSize);
+ throw new BadMessageException(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431,"Header size "+(_size+length)+">"+_maxSize);
}
}
diff --git a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java
index abd8ab7472f..fce577bbb57 100644
--- a/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java
+++ b/jetty-http2/http2-hpack/src/test/java/org/eclipse/jetty/http2/hpack/HpackTest.java
@@ -101,7 +101,7 @@ public class HpackTest
public void encodeDecodeTooLargeTest()
{
HpackEncoder encoder = new HpackEncoder();
- HpackDecoder decoder = new HpackDecoder(4096,101);
+ HpackDecoder decoder = new HpackDecoder(4096,164);
ByteBuffer buffer = BufferUtil.allocate(16*1024);
HttpFields fields0 = new HttpFields();
@@ -132,7 +132,7 @@ public class HpackTest
}
catch(BadMessageException e)
{
- assertEquals(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413,e.getCode());
+ assertEquals(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE_431,e.getCode());
}
}
diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java
index 69f8c7fcd1b..98a726f01de 100644
--- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java
+++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java
@@ -101,15 +101,6 @@ public class HTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnectionF
return settings;
}
- @Override
- public void onSettings(Session session, SettingsFrame frame)
- {
- HttpConfiguration httpConfig = getHttpConfiguration();
- Integer mhls = frame.getSettings().get(SettingsFrame.MAX_HEADER_LIST_SIZE);
- if (mhls != null && mhls < httpConfig.getResponseHeaderSize())
- LOG.warn("MAX_HEADER_LIST_SIZE<{} for {}",getHttpConfiguration().getResponseHeaderSize(),session);
- }
-
@Override
public Stream.Listener onNewStream(Stream stream, HeadersFrame frame)
{
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
index 05d99ea1d7f..b7f127b418a 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
@@ -762,7 +762,7 @@ public class HttpConnectionTest
"Cookie: "+cookie+"\r\n"+
"\r\n"
);
- checkContains(response, offset, "HTTP/1.1 413");
+ checkContains(response, offset, "HTTP/1.1 431");
}
catch(Exception e)
{
@@ -791,8 +791,8 @@ public class HttpConnectionTest
request.append("\r\n");
String response = connector.getResponses(request.toString());
- offset = checkContains(response, offset, "HTTP/1.1 413");
- checkContains(response, offset, "reason: Request Entity Too Large"); + offset = checkContains(response, offset, "HTTP/1.1 431"); + checkContains(response, offset, "