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.
@@ -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 ) {
0 commit comments