You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If we have a maximumContentLength, and this is a fixed content length request, before we read any bytes, fail early.
208
204
// For good measure do this last so if anyone downstream wants to read from the InputStream they could in theory because
209
205
// we will have set up the InputStream.
210
-
if (contentLength != null && maximumContentLength != -1) {
211
-
if (contentLength > maximumContentLength) {
212
-
StringdetailedMessage = "The maximum request size has been exceeded. The reported Content-Length is [" + contentLength + "] and the maximum request size is [" + maximumContentLength + "] bytes.";
StringdetailedMessage = "The maximum request size has been exceeded. The reported Content-Length is [" + contentLength + "] and the maximum request size is [" + maximumContentLength + "] bytes.";
Copy file name to clipboardExpand all lines: src/main/java/io/fusionauth/http/util/HTTPTools.java
+8-14Lines changed: 8 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -296,14 +296,9 @@ public static void parseRequestPreamble(PushbackInputStream inputStream, int max
296
296
297
297
intread = 0;
298
298
intindex = 0;
299
-
intbytesRead = 0;
300
-
booleanreadExceeded = false;
299
+
intpremableLength = 0;
301
300
302
301
while (state != RequestPreambleState.Complete) {
303
-
if (readExceeded) {
304
-
thrownewRequestHeadersTooLargeException(maxRequestHeaderSize, "The maximum size of the request header has been exceeded. The maximum size is [" + maxRequestHeaderSize + "] bytes.");
305
-
}
306
-
307
302
longstart = System.currentTimeMillis();
308
303
read = inputStream.read(requestBuffer);
309
304
@@ -316,17 +311,10 @@ public static void parseRequestPreamble(PushbackInputStream inputStream, int max
316
311
logger.trace("Read [{}] from client for preamble.", read);
317
312
318
313
// Tell the callback that we've read at least one byte
319
-
if (bytesRead == 0) {
314
+
if (premableLength == 0) {
320
315
readObserver.run();
321
316
}
322
317
323
-
// bytesRead will include bytes that are read past the end of the preamble. This should be ok because we will only throw an exception
324
-
// for readExceeded once we have reached this state AND we are not yet in a complete state.
325
-
// - If we exceed the max header size from this read, as long as this buffer includes the entire preamble we will not throw
for (index = 0; index < read && state != RequestPreambleState.Complete; index++) {
331
319
// If there is a state transition, store the value properly and reset the builder (if needed)
332
320
bytech = requestBuffer[index];
@@ -352,6 +340,12 @@ public static void parseRequestPreamble(PushbackInputStream inputStream, int max
352
340
353
341
state = nextState;
354
342
}
343
+
344
+
// index is the number of bytes we processed as part of the preamble
345
+
premableLength += index;
346
+
if (premableLength > maxRequestHeaderSize) {
347
+
thrownewRequestHeadersTooLargeException(maxRequestHeaderSize, "The maximum size of the request header has been exceeded. The maximum size is [" + maxRequestHeaderSize + "] bytes.");
0 commit comments