Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation lacks information/examples on setting Jetty request size #1021

Open
editicalu opened this issue Jun 4, 2018 · 7 comments
Open

Comments

@editicalu
Copy link

I read that it is possible now to tweak the Spark internal Jetty server #314. However, I can't find any example on how to use this to change the request size, as my project gets "Form too large" exceptions all the time.

It would be useful to have at least an example on the official documentation.

@jarlah
Copy link

jarlah commented Oct 8, 2018

A quick google search tells me how.
But thats not guaranteed to be the correct way. Https://blog.codecentric.de/en/2017/07/fine-tuning-embedded-jetty-inside-spark-framework/

@jarlah
Copy link

jarlah commented Oct 8, 2018

I have added some jetty overrides in one of my OS projects. The use of spark however is temporary. I am trying to make the server framework agnostic.

You can see what i have done here

https://github.com/freeacs/freeacs/blob/master/tr069/src/main/java/com/github/freeacs/App.java

@editicalu
Copy link
Author

editicalu commented Oct 8, 2018 via email

@toyg
Copy link

toyg commented Feb 11, 2019

I wrote a more comprehensive post: http://blog.pythonaro.com/2019/02/how-to-customise-jetty-embedded-in.html

Because of the current architecture, the topic is not simple enough to fit in the fancy web docs. I think there might be some work to be done to expose this sort of thing in an easy way. To be fair, some of the limitations are due to jetty himself.

@ilvez
Copy link

ilvez commented Mar 26, 2020

@editicalu I would have been nice to describe the workaround as well.

Anyway currently I'm left to digging into Jetty internals to fix "Form too large" issue. Some official documentation from Spark side would be nice.

@ilvez
Copy link

ilvez commented Mar 26, 2020

Anyway, got it working with accepted answer from here: https://stackoverflow.com/questions/49054092/how-do-i-configure-jetty-to-allow-larger-forms-when-used-with-spark-framework

Code example:

public class Main {
  public static void main(String ...args) {
    CustomJettyServerFactory customJettyServerFactory = new CustomJettyServerFactory();
    EmbeddedServers.add(
        EmbeddedServers.Identifiers.JETTY, 
        new EmbeddedJettyFactory(customJettyServerFactory));
  }
}

class CustomJettyServerFactory implements JettyServerFactory {
  @Override
  public Server create(int maxThreads, int minThreads, int threadTimeoutMillis) {
    Server server = new Server();
    server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 1000000);
    return server;
  }

  @Override
  public Server create(ThreadPool threadPool) {
    return null;
  }
}

@editicalu
Copy link
Author

@ilvez the workaround was to make my requests smaller. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants