Skip to content

Commit d3d1b03

Browse files
committed
merge in main
2 parents c86206f + 10fc594 commit d3d1b03

24 files changed

+1297
-227
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Latest versions
44

5-
* Latest stable version: `1.2.0`
5+
* Latest stable version: `1.3.0`
66
* Now with 100% more virtual threads!
77
* Prior stable version `0.3.7`
88

@@ -27,20 +27,20 @@ To add this library to your project, you can include this dependency in your Mav
2727
<dependency>
2828
<groupId>io.fusionauth</groupId>
2929
<artifactId>java-http</artifactId>
30-
<version>1.2.0</version>
30+
<version>1.3.0</version>
3131
</dependency>
3232
```
3333

3434
If you are using Gradle, you can add this to your build file:
3535

3636
```groovy
37-
implementation 'io.fusionauth:java-http:1.2.0'
37+
implementation 'io.fusionauth:java-http:1.3.0'
3838
```
3939

4040
If you are using Savant, you can add this to your build file:
4141

4242
```groovy
43-
dependency(id: "io.fusionauth:java-http:1.2.0")
43+
dependency(id: "io.fusionauth:java-http:1.3.0")
4444
```
4545

4646
## Examples Usages:

build.savant

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ restifyVersion = "4.2.1"
1818
slf4jVersion = "2.0.17"
1919
testngVersion = "7.11.0"
2020

21-
project(group: "io.fusionauth", name: "java-http", version: "1.2.0", licenses: ["ApacheV2_0"]) {
21+
project(group: "io.fusionauth", name: "java-http", version: "1.3.0", licenses: ["ApacheV2_0"]) {
2222
workflow {
2323
fetch {
2424
// Dependency resolution order:

java-http.ipr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
<option name="addBlankAfter" value="false" />
1010
</LanguageOptions>
1111
</component>
12+
<component name="GitScope">
13+
<option name="currentTabIndex" value="1" />
14+
<option name="modelData" value="[{&quot;targetBranchMap&quot;:{&quot;value&quot;:{&quot;/Users/bpontarelli/dev/inversoft/fusionauth/java-http&quot;:&quot;HEAD~5&quot;}},&quot;customTabName&quot;:&quot;HEAD~5&quot;}]" />
15+
</component>
1216
<component name="InspectionProjectProfileManager">
1317
<profile version="1.0">
1418
<option name="myName" value="Project Default" />

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.fusionauth</groupId>
44
<artifactId>java-http</artifactId>
5-
<version>1.2.0</version>
5+
<version>1.3.0</version>
66
<packaging>jar</packaging>
77

88
<name>Java HTTP library (client and server)</name>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
/**
19+
* Thrown when the request headers exceeds the total configured maximum size.
20+
*
21+
* @author Daniel DeGroff
22+
*/
23+
public class RequestHeadersTooLargeException extends HTTPProcessingException {
24+
public long maximumRequestHeadersSize;
25+
26+
public RequestHeadersTooLargeException(long maximumRequestHeadersSize, String detailedMessage) {
27+
super(431, "Request Header Fields Too Large", detailedMessage);
28+
this.maximumRequestHeadersSize = maximumRequestHeadersSize;
29+
}
30+
}

src/main/java/io/fusionauth/http/io/MultipartConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public class MultipartConfiguration {
3030

3131
private long maxFileSize = 1024 * 1024; // 1 Megabyte
3232

33-
private long maxRequestSize = 10 * 1024 * 1024; // 10 Megabyte
33+
private long maxRequestSize = 10 * 1024 * 1024; // 10 Megabytes
3434

35-
private int multipartBufferSize = 8 * 1024; // 8 Kilobyte
35+
private int multipartBufferSize = 8 * 1024; // 8 Kilobytes
3636

3737
private String temporaryFileLocation = System.getProperty("java.io.tmpdir");
3838

src/main/java/io/fusionauth/http/server/Configurable.java

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.nio.file.Path;
1919
import java.time.Duration;
20+
import java.util.Map;
2021

2122
import io.fusionauth.http.io.MultipartConfiguration;
2223
import io.fusionauth.http.log.LoggerFactory;
@@ -48,7 +49,7 @@ default T withBaseDir(Path baseDir) {
4849
}
4950

5051
/**
51-
* Sets the buffer size for the chunked input stream. Defaults to 4k.
52+
* Sets the buffer size for the chunked input stream. Defaults to 4 Kilobytes.
5253
*
5354
* @param chunkedBufferSize the buffer size used to read a request body that was encoded using 'chunked' transfer-encoding.
5455
* @return This.
@@ -193,6 +194,52 @@ default T withMaxPendingSocketConnections(int maxPendingSocketConnections) {
193194
return (T) this;
194195
}
195196

197+
/**
198+
* Sets the maximum size of the HTTP request body by Content-Type. If this limit is exceeded, the connection will be closed.
199+
* <p>
200+
* The default size is identified by the "*" key. This default value will be used if a more specific value has not been configured for the
201+
* requested Content-Type.
202+
* <p>
203+
* You may also use wildcards to match one to many subtypes. For example, "application/*" will provide a max size for all content types
204+
* beginning with application/ when an exact match has not been configured.
205+
* <p>
206+
* An example lookup for the Content-Type "application/x-www-form-urlencoded" is:
207+
* <ol>
208+
* <li>application/x-www-form-urlencoded</li>
209+
* <li>application/*</li>
210+
* <li>*</li>
211+
* </ol>
212+
* <p>
213+
* If the provided configuration does not contain the initial default identified by the "*" key, the server default value will be retained.
214+
* key.
215+
* <p>
216+
* Set any value to -1 to disable this limitation.
217+
* <p>
218+
* Defaults to 128 Megabytes for the default "*" and 10 Megabytes for "application/x-www-form-urlencoded".
219+
*
220+
* @param maxRequestBodySize a map specifying the maximum size in bytes for the HTTP request body by Content-Type
221+
* @return This.
222+
*/
223+
default T withMaxRequestBodySize(Map<String, Integer> maxRequestBodySize) {
224+
configuration().withMaxRequestBodySize(maxRequestBodySize);
225+
return (T) this;
226+
}
227+
228+
/**
229+
* Sets the maximum size of the HTTP request header. The request header includes the HTTP request line, and all HTTP request headers,
230+
* essentially everything except the request body. If this maximum limit is exceeded, the connection will be closed. Defaults to 128
231+
* Kilobytes.
232+
* <p>
233+
* Set this to -1 to disable this limitation.
234+
*
235+
* @param maxRequestHeaderSize the maximum size in bytes for the HTTP request header
236+
* @return This.
237+
*/
238+
default T withMaxRequestHeaderSize(int maxRequestHeaderSize) {
239+
configuration().withMaxRequestHeaderSize(maxRequestHeaderSize);
240+
return (T) this;
241+
}
242+
196243
/**
197244
* Sets the base directory for this server. This is passed to the HTTPContext, which is available from this class. This defaults to the
198245
* current working directory of the process. Defaults to 100,000.
@@ -206,7 +253,8 @@ default T withMaxRequestsPerConnection(int maxRequestsPerConnection) {
206253
}
207254

208255
/**
209-
* This configures the maximum size of a chunk in the response when the server is using chunked response encoding. Defaults to 16k.
256+
* This configures the maximum size of a chunk in the response when the server is using chunked response encoding. Defaults to 16
257+
* Kilobytes.
210258
*
211259
* @param size The size in bytes.
212260
* @return This.
@@ -218,7 +266,7 @@ default T withMaxResponseChunkSize(int size) {
218266

219267
/**
220268
* Sets the maximum number of bytes the server will allow worker threads to drain after calling the request handler. If the request
221-
* handler does not read all the bytes, and this limit is exceeded the connection will be closed. Defaults to 128k bytes.
269+
* handler does not read all the bytes, and this limit is exceeded the connection will be closed. Defaults to 128 Kilobytes bytes.
222270
*
223271
* @param maxBytesToDrain The maximum number of bytes to drain from the InputStream if the request handler did not read all the available
224272
* bytes.
@@ -254,7 +302,7 @@ default T withMinimumWriteThroughput(long bytesPerSecond) {
254302
}
255303

256304
/**
257-
* Sets the size of the buffer that is used to process the multipart request body. This defaults to 16k.
305+
* Sets the size of the buffer that is used to process the multipart request body. This defaults to 16 Kilobytes.
258306
*
259307
* @param multipartBufferSize The size of the buffer.
260308
* @return This.
@@ -306,7 +354,7 @@ default T withReadThroughputCalculationDelayDuration(Duration duration) {
306354
}
307355

308356
/**
309-
* Sets the size of the buffer that is used to process the HTTP request. This defaults to 16k.
357+
* Sets the size of the buffer that is used to process the HTTP request. This defaults to 16 Kilobytes.
310358
*
311359
* @param requestBufferSize The size of the buffer.
312360
* @return This.
@@ -319,9 +367,11 @@ default T withRequestBufferSize(int requestBufferSize) {
319367
/**
320368
* Sets the size of the buffer that is used to store the HTTP response before any bytes are written back to the client. This is useful
321369
* when the server is generating the response but encounters an error. In this case, the server will throw out the response and change to
322-
* a 500 error response. This defaults to 64k. Negative values disable the response buffer.
370+
* a 500 error response. This defaults to 64 Kilobytes. Negative values disable the response buffer.
371+
* <p>
372+
* Set to -1 do disable buffering completely.
323373
*
324-
* @param responseBufferSize The size of the buffer. Set to -1 to disable buffering completely.
374+
* @param responseBufferSize The size of the buffer.
325375
* @return This.
326376
*/
327377
default T withResponseBufferSize(int responseBufferSize) {

src/main/java/io/fusionauth/http/server/HTTPRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public Map<String, List<String>> getFormData() {
382382
String contentType = getContentType();
383383
if (contentType != null && contentType.equalsIgnoreCase(ContentTypes.Form)) {
384384
byte[] body = getBodyBytes();
385-
HTTPTools.parseEncodedData(body, 0, body.length, formData);
385+
HTTPTools.parseEncodedData(body, 0, body.length, getCharacterEncoding(), formData);
386386
} else if (isMultipart()) {
387387
try {
388388
multipartStreamProcessor.process(inputStream, formData, files, multipartBoundary.getBytes());

0 commit comments

Comments
 (0)