Open editicalu opened 6 years ago
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/
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
Thank you, but I already worked around the problem, so it is no issue for me anymore. However, I guess this would be useful for newcomers.
On 8 October 2018 20:26:15 GMT+02:00, "Jarl André Hübenthal" notifications@github.com wrote:
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
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/perwendel/spark/issues/1021#issuecomment-427933869
-- Sent from my Android device with K-9 Mail. Please excuse my brevity.
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.
@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.
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;
}
}
@ilvez the workaround was to make my requests smaller. :)
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.