How to change the maximum and maximum number of POST data in Spark

The maximum form value in Jetty is 200KB by default. Spark uses Jetty, so it's similar to this.

It seems that there are various setting methods for Jetty alone, but it is quite annoying for Spark.

I will omit the details, but the method is as follows.

python


public class Main {
  public static void main(String[] args) {
    EmbeddedServers.add(EmbeddedServers.Identifiers.JETTY, new EmbeddedJettyFactory(new MyJettyServerFactory()));

    get("/", () -> "Hello Spark!");
  }
}

class MyJettyServerFactory implements JettyServerFactory {
    /**
     * Creates a Jetty server.
     *
     * @param maxThreads          maxThreads
     * @param minThreads          minThreads
     * @param threadTimeoutMillis threadTimeoutMillis
     * @return a new jetty server instance
     */
	@Override
    public Server create(int maxThreads, int minThreads, int threadTimeoutMillis) {
        Server server;

        if (maxThreads > 0) {
            int max = maxThreads;
            int min = (minThreads > 0) ? minThreads : 8;
            int idleTimeout = (threadTimeoutMillis > 0) ? threadTimeoutMillis : 60000;

            server = new Server(new QueuedThreadPool(max, min, idleTimeout));
        } else {
            server = new Server();
        }

        server.setAttribute("org.eclipse.jetty.server.Request.maxFormKeys", 20000); //Maximum number of POST data
        server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 5000000); //Maximum value of POST data

        return server;
    }

    /**
     * Creates a Jetty server with supplied thread pool
     * @param threadPool thread pool
     * @return a new jetty server instance
     */
	@Override
    public Server create(ThreadPool threadPool) {
        return threadPool != null ? new Server(threadPool) : new Server();
    }
}

By the way, unless you get the value of the form programmatically, no error will occur. What about the specifications?

Recommended Posts

How to change the maximum and maximum number of POST data in Spark
How to determine the number of parallels
How to delete large amounts of data in Rails and concerns
How to find the total number of pages when paging in Java
How to change the value of a variable at a breakpoint in intelliJ
http: // localhost: How to change the port number
[Swift] How to get the number of elements in an array (super basic)
[Swift] How to change the order of Bar Items in Tab Bar Controller [Beginner]
How to make a unique combination of data in the rails intermediate table
[Java] How to get the maximum value of HashMap
[Rails] How to change the column name of the table
Set the maximum number of characters in UITextField in RxSwift
How to change a string in an array to a number in Ruby
Command to check the number and status of Java threads
How to change the setting value of Springboot Hikari CP
How to derive the last day of the month in Java
How to change the contents of the jar file without decompressing
How to check the extension and size of uploaded files
How to change BackgroundColor etc. of NavigationBar in Swift UI
How to get parameters in Spark
How to manage the difference in each environment with yml without increasing the number of RAILS_ENV
[Swift] How to dynamically change the height of the toolbar on the keyboard
[Rails] How to get the URL of the transition source and redirect
[Swift5] How to get an array and the complement of arrays
How to set the IP address and host name of CentOS8
How to POST JSON in Java-Method using OkHttp3 and method using HttpUrlConnection-
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
[Rails] How to introduce kaminari with Slim and change the design
[Rails] How to change the page title of the browser for each page
[jOOQ] How to CASE WHEN in the WHERE / AND / OR clause
Method to add the number of years and get the end of the month
How to get the id of PRIMAY KEY auto_incremented in MyBatis
How to install the language used in Ubuntu and how to build the environment
How to get and add data from Firebase Firestore in Ruby
[chown] How to change the owner of a file or directory
I want to change the value of Attribute in Selenium of Ruby
How to get the length of an audio file in java
How to increment the value of Map in one line in Java
[Docker] How to back up and restore the DB data of Rails application on docker-compose [MySQL]
Method definition location Summary of how to check When defined in the project and Rails / Gem
How to change app name in rails
How to get date data in Ruby
How to change the timezone on Ubuntu
Ransack sort_link How to change the color!
How to sort the List of SelectItem
How to find the tens and ones
How to get the date in java
How to overwrite Firebase data in Swift
How to set the indent to 2 single-byte spaces in the JAXB implementation of the JDK
Set the number of seconds for fast forward and rewind in ExoPlayer
Confirmation and refactoring of the flow from request to controller in [httpclient]
How to constrain the action of the transition destination when not logged in
How to get the absolute path of a directory running in Java
[Java improvement case] How to reach the limit of self-study and beyond
Find the maximum and minimum of the five numbers you entered in Java
[Rails] How to create a table, add a column, and change the column type
[Rails] The cause of not being able to post was in form_with
Android development, how to check null in the value of JSON object
[swift5] How to change the color of TabBar or the color of item of TabBar with code
How to insert processing with any number of elements in iterative processing in Ruby
How to create your own annotation in Java and get the value