2626import edu .umd .cs .findbugs .annotations .NonNull ;
2727import edu .umd .cs .findbugs .annotations .Nullable ;
2828import io .jooby .internal .SslContextProvider ;
29+ import io .jooby .output .BufferOptions ;
2930
3031/**
3132 * Available server options. To load server options from configuration files, just do:
@@ -47,7 +48,7 @@ public class ServerOptions {
4748 public static final int SERVER_PORT = Integer .parseInt (System .getProperty ("server.port" , "8080" ));
4849
4950 /**
50- * Default application secure port <code>8443</code> or the value of system property <code>
51+ * Default application secures port <code>8443</code> or the value of system property <code>
5152 * server.securePort</code>.
5253 */
5354 public static final int SEVER_SECURE_PORT =
@@ -70,9 +71,6 @@ public class ServerOptions {
7071
7172 private static final String LOCAL_HOST = "0.0.0.0" ;
7273
73- /** Buffer size used by server. Usually for reading/writing data. */
74- private int bufferSize = _16KB ;
75-
7674 /** Number of available threads, but never smaller than <code>2</code>. */
7775 public static final int IO_THREADS = Runtime .getRuntime ().availableProcessors () * 2 ;
7876
@@ -100,6 +98,8 @@ public class ServerOptions {
10098 /** Name of server: Jetty, Netty or Undertow. */
10199 private String server ;
102100
101+ private BufferOptions buffer = BufferOptions .defaults ();
102+
103103 /**
104104 * Maximum request size in bytes. Request exceeding this value results in {@link
105105 * io.jooby.StatusCode#REQUEST_ENTITY_TOO_LARGE} response. Default is <code>10mb</code>.
@@ -143,8 +143,11 @@ public class ServerOptions {
143143 if (conf .hasPath ("server.name" )) {
144144 options .setServer (conf .getString ("server.name" ));
145145 }
146- if (conf .hasPath ("server.bufferSize" )) {
147- options .setBufferSize (conf .getInt ("server.bufferSize" ));
146+ if (conf .hasPath ("server.buffer.size" )) {
147+ options .buffer .setSize (conf .getInt ("server.buffer.size" ));
148+ }
149+ if (conf .hasPath ("server.buffer.useDirectBuffers" )) {
150+ options .buffer .setDirectBuffers (conf .getBoolean ("server.buffer.useDirectBuffers" ));
148151 }
149152 if (conf .hasPath ("server.defaultHeaders" )) {
150153 options .setDefaultHeaders (conf .getBoolean ("server.defaultHeaders" ));
@@ -191,7 +194,7 @@ public String toString() {
191194 buff .append (", ioThreads: " ).append (Optional .ofNullable (ioThreads ).orElse (IO_THREADS ));
192195 }
193196 buff .append (", workerThreads: " ).append (getWorkerThreads ());
194- buff .append (", bufferSize : " ).append (bufferSize );
197+ buff .append (", buffer : " ).append (getBuffer () );
195198 buff .append (", maxRequestSize: " ).append (maxRequestSize );
196199 buff .append (", httpsOnly: " ).append (httpsOnly );
197200 if (compressionLevel != null ) {
@@ -405,24 +408,12 @@ public boolean getDefaultHeaders() {
405408 return this ;
406409 }
407410
408- /**
409- * Server buffer size in bytes. Default is: <code>16kb</code>. Used for reading/writing data.
410- *
411- * @return Server buffer size in bytes. Default is: <code>16kb</code>. Used for reading/writing
412- * data.
413- */
414- public int getBufferSize () {
415- return bufferSize ;
411+ public BufferOptions getBuffer () {
412+ return buffer ;
416413 }
417414
418- /**
419- * Set buffer size.
420- *
421- * @param bufferSize Buffer size.
422- * @return This options.
423- */
424- public @ NonNull ServerOptions setBufferSize (int bufferSize ) {
425- this .bufferSize = bufferSize ;
415+ public ServerOptions setBuffer (@ NonNull BufferOptions buffer ) {
416+ this .buffer = buffer ;
426417 return this ;
427418 }
428419
0 commit comments