1717
1818import java .nio .file .Path ;
1919import java .time .Duration ;
20+ import java .util .Map ;
2021
2122import io .fusionauth .http .io .MultipartConfiguration ;
2223import 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.
@@ -184,6 +185,52 @@ default T withMaxPendingSocketConnections(int maxPendingSocketConnections) {
184185 return (T ) this ;
185186 }
186187
188+ /**
189+ * Sets the maximum size of the HTTP request body by Content-Type. If this limit is exceeded, the connection will be closed.
190+ * <p>
191+ * 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
192+ * requested Content-Type.
193+ * <p>
194+ * You may also use wildcards to match one to many subtypes. For example, "application/*" will provide a max size for all content types
195+ * beginning with application/ when an exact match has not been configured.
196+ * <p>
197+ * An example lookup for the Content-Type "application/x-www-form-urlencoded" is:
198+ * <ol>
199+ * <li>application/x-www-form-urlencoded</li>
200+ * <li>application/*</li>
201+ * <li>*</li>
202+ * </ol>
203+ * <p>
204+ * If the provided configuration does not contain the initial default identified by the "*" key, the server default value will be retained.
205+ * key.
206+ * <p>
207+ * Set any value to -1 to disable this limitation.
208+ * <p>
209+ * Defaults to 128 Megabytes for the default "*" and 10 Megabytes for "application/x-www-form-urlencoded".
210+ *
211+ * @param maxRequestBodySize a map specifying the maximum size in bytes for the HTTP request body by Content-Type
212+ * @return This.
213+ */
214+ default T withMaxRequestBodySize (Map <String , Integer > maxRequestBodySize ) {
215+ configuration ().withMaxRequestBodySize (maxRequestBodySize );
216+ return (T ) this ;
217+ }
218+
219+ /**
220+ * Sets the maximum size of the HTTP request header. The request header includes the HTTP request line, and all HTTP request headers,
221+ * essentially everything except the request body. If this maximum limit is exceeded, the connection will be closed. Defaults to 128
222+ * Kilobytes.
223+ * <p>
224+ * Set this to -1 to disable this limitation.
225+ *
226+ * @param maxRequestHeaderSize the maximum size in bytes for the HTTP request header
227+ * @return This.
228+ */
229+ default T withMaxRequestHeaderSize (int maxRequestHeaderSize ) {
230+ configuration ().withMaxRequestHeaderSize (maxRequestHeaderSize );
231+ return (T ) this ;
232+ }
233+
187234 /**
188235 * Sets the base directory for this server. This is passed to the HTTPContext, which is available from this class. This defaults to the
189236 * current working directory of the process. Defaults to 100,000.
@@ -197,7 +244,8 @@ default T withMaxRequestsPerConnection(int maxRequestsPerConnection) {
197244 }
198245
199246 /**
200- * This configures the maximum size of a chunk in the response when the server is using chunked response encoding. Defaults to 16k.
247+ * This configures the maximum size of a chunk in the response when the server is using chunked response encoding. Defaults to 16
248+ * Kilobytes.
201249 *
202250 * @param size The size in bytes.
203251 * @return This.
@@ -209,7 +257,7 @@ default T withMaxResponseChunkSize(int size) {
209257
210258 /**
211259 * Sets the maximum number of bytes the server will allow worker threads to drain after calling the request handler. If the request
212- * handler does not read all the bytes, and this limit is exceeded the connection will be closed. Defaults to 128k bytes.
260+ * handler does not read all the bytes, and this limit is exceeded the connection will be closed. Defaults to 128 Kilobytes bytes.
213261 *
214262 * @param maxBytesToDrain The maximum number of bytes to drain from the InputStream if the request handler did not read all the available
215263 * bytes.
@@ -245,7 +293,7 @@ default T withMinimumWriteThroughput(long bytesPerSecond) {
245293 }
246294
247295 /**
248- * Sets the size of the buffer that is used to process the multipart request body. This defaults to 16k .
296+ * Sets the size of the buffer that is used to process the multipart request body. This defaults to 16 Kilobytes .
249297 *
250298 * @param multipartBufferSize The size of the buffer.
251299 * @return This.
@@ -297,7 +345,7 @@ default T withReadThroughputCalculationDelayDuration(Duration duration) {
297345 }
298346
299347 /**
300- * Sets the size of the buffer that is used to process the HTTP request. This defaults to 16k .
348+ * Sets the size of the buffer that is used to process the HTTP request. This defaults to 16 Kilobytes .
301349 *
302350 * @param requestBufferSize The size of the buffer.
303351 * @return This.
@@ -310,9 +358,11 @@ default T withRequestBufferSize(int requestBufferSize) {
310358 /**
311359 * 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
312360 * when the server is generating the response but encounters an error. In this case, the server will throw out the response and change to
313- * a 500 error response. This defaults to 64k. Negative values disable the response buffer.
361+ * a 500 error response. This defaults to 64 Kilobytes. Negative values disable the response buffer.
362+ * <p>
363+ * Set to -1 do disable buffering completely.
314364 *
315- * @param responseBufferSize The size of the buffer. Set to -1 to disable buffering completely.
365+ * @param responseBufferSize The size of the buffer.
316366 * @return This.
317367 */
318368 default T withResponseBufferSize (int responseBufferSize ) {
0 commit comments