[jetty-users] ImageIO in servlet: should I close the httpResp.getOutputStream() and how to set Content-Length?

2019-10-04 Thread Alexander Farber
Good morning, I am using Jetty 9.4.21.v20190926 - as a standalone server behind HAProxy and also I compile my custom WAR servlet against it. It serves Websockets, GET, POST requests and works very well, thank you! However now I would like to generate a PNG file using ImageIO and while the code

Re: [jetty-users] ServletContextListener defers server start

2019-10-04 Thread Greg Wilkins
Dirk, Note that you can actually achieve this with just a little bit of work: Write a simple context (extend context handler) that all it does is send a 503 with whatever message you want. Deploy both that context and your context at the same context path. The 503 context will handle all the

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Glen Peterson
It *works* with http1.1 (I will also look more at the fat-jar thing): $ curl --http1.1 --verbose --insecure https://localhost:8443 -D headers.txt * Rebuilt URL to: https://localhost:8443/ * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8443 (#0) * ALPN,

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Glen Peterson
Yes. It has a single line: org.eclipse.jetty.http.Http1FieldPreEncoder Should it have 2 lines? What if I just disallow that file altogether? On Fri, Oct 4, 2019 at 8:10 PM Greg Wilkins wrote: > > Glen, > > it is not a matter of if the classes are in the jar or not. It is a > matter of if

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Glen Peterson
SWEET! That fixed it. I just added the line: org.eclipse.jetty.http2.hpack.HpackFieldPreEncoder And it worked! Hallelujah! Is that something I can configure with code? On Fri, Oct 4, 2019 at 8:12 PM Glen Peterson wrote: > Yes. It has a single line: >

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Glen Peterson
I may have been able to really simplify my example. Here's the entire main method that works when run from class files, and fails when run from the jar: val bb: ByteBuffer = ByteBuffer.allocate(100) PreEncodedHttpField("hello", "world").putTo(bb, HttpVersion.HTTP_1_0) logger.info("hello world

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Greg Wilkins
A good tool to create a fat jar should merged META-INF service files for you. There are probably a couple of other ones that need to be merged in the code base... more so once you go to jetty 10. cheers On Sat, 5 Oct 2019 at 10:16, Glen Peterson wrote: > SWEET! That fixed it. I just added

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Greg Wilkins
Glen, it is not a matter of if the classes are in the jar or not. It is a matter of if the META-INF/services has been correctly configured to load them with the ServiceLoader. Does your jar have a META-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder file and if so, what is it's

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Greg Wilkins
I'm guessing the problem is the way you make your fat jar you must not be correctly combining the META-INF/services/org.eclipse.jetty.http.HttpFieldPreEncoder files To run both http1 and http2, you need that file to exist in the jar and to contain: org.eclipse.jetty.http.Http1FieldPreEncoder

Re: [jetty-users] ImageIO in servlet: should I close the httpResp.getOutputStream() and how to set Content-Length?

2019-10-04 Thread Alexander Farber
Thank you, Joakim! ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

Re: [jetty-users] ServletContextListener defers server start

2019-10-04 Thread Joakim Erdfelt
Sounds like the initial deployment on Server.start() is the reason you are experiencing this. Your environment would need to delay deployment until after the server has started up. That would be a new feature / configuration (and not that hard to implement either) Can you file an issue for a new

Re: [jetty-users] ImageIO in servlet: should I close the httpResp.getOutputStream() and how to set Content-Length?

2019-10-04 Thread Joakim Erdfelt
Inline ... On Fri, Oct 4, 2019 at 4:05 AM Alexander Farber wrote: > Good morning, > > I am using Jetty 9.4.21.v20190926 - as a standalone server behind HAProxy > and also I compile my custom WAR servlet against it. > > It serves Websockets, GET, POST requests and works very well, thank you! >

[jetty-users] ServletContextListener defers server start

2019-10-04 Thread Dirk Olmes
Hi, I'm using an embedded Jetty to set up a servlet context. My code looks quite similar to what's in the "Embedding ServletContexts" section of the "Embedding Jetty" chapter of the Jetty docs. I noticed that the server (more correctly the ServerConnector) won't be ready to accept connections

Re: [jetty-users] ImageIO in servlet: should I close the httpResp.getOutputStream() and how to set Content-Length?

2019-10-04 Thread Bill Ross
Plus you'd just be serving raw bytes, which saves time parsing the image format and reconstituting compressed pngs or jpegs for example. It's what I have here: http://phobrain.com/pr/home/view.html Bill On 10/4/19 6:49 AM, Bill Ross wrote: It looks like you're reading the whole png before

Re: [jetty-users] ImageIO in servlet: should I close the httpResp.getOutputStream() and how to set Content-Length?

2019-10-04 Thread Bill Ross
It looks like you're reading the whole png before sending, where you could save latency and memory for big files and have a good general method by using the static resource servlet given here: http://stackoverflow.com/questions/132052/servlet-for-serving-static-content Bill On 10/4/19 2:04

Re: [jetty-users] ImageIO in servlet: should I close the httpResp.getOutputStream() and how to set Content-Length?

2019-10-04 Thread Alexander Farber
Hi Bill, no - I have just listed only a part of my real program which scales, composes several PNGs to one and also adds shapes and texts to it. So I still wonder: 1. How to set Content-Length (despite gzip encoding)? 2. And if I should close the output stream or not (won't that break

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Glen Peterson
I changed the logging configuration from INFO to DEBUG and found this error when Jetty tries to serve the request: Sending HeadersFrame@676f5d6c#1{end=false} Appended HeadersFrame@676f5d6c#1{end=false}, entries=1 Flushing HTTP2ServerSession@74a58163{l:/0:0:0:0:0:0:0:1:8443 <->

Re: [jetty-users] curl: (56) Unexpected EOF

2019-10-04 Thread Joakim Erdfelt
Interesting, I wonder if you are hitting the response headers issues with regards to HTTP/2. See: https://github.com/eclipse/jetty.project/issues/3956 and https://github.com/eclipse/jetty.project/issues/4115 Can you run curl again, but with HTTP/1.1? $ curl --http1.1 --verbose What kind