r/java • • Jul 25 '22

Latest version of Microhttp, an event-driven, zero-dependency, pure-Java web server with 500 LOC, capable of 1,000,000+ requests per second on commodity EC2 hardware.

https://github.com/ebarlas/microhttp
136 Upvotes

35 comments sorted by

View all comments

Show parent comments

9

u/0x256 Jul 26 '22

Then you should document more clearly that this is an incomplete HTTP 1.1 implementation and should not be used in internet-facing applications. At least 100‐continue should be implemented though, as a reverse proxy like nginx won't protect you from that.

2

u/agentoutlier Jul 26 '22

To be fair OOB both Undertow and I believe Netty do not support expect 100. Jetty does.

Some frameworks You need to configure it or use some add on classes.

I imagine this library could do similar.

2

u/0x256 Jul 26 '22 edited Jul 26 '22

I doubt that, and for undertow I know you are wrong. 100-continue is not a SHOULD feature, if a client uses it the server MUST handle it or the request will run into a timeout. For highly configurable 'know-what-you-are-doing' libraries like Undertow or Netty this may be pluggable, but it is supported or that would be a serious bug.

Edit: You probably mean that it is not enabled or magically handled by default in Undertow. Yes, because undertow and netty implement almost anything in 'handlers' you have to manually add and configure. The idea of 100-continue is that the application can decide whether it wants to answer immediately, or needs the offered request body for a result. An example would be a client that wants to upload a file, but only if it is not already present on the server. With 100-continue, this can be implemented in a single atomic request without wasting bandwidth in the case the file is not needed. Undertow lets you handle that explicitly (with HttpContinueAcceptingHandler and a Predicate). Other frameworks may automatically send the 100-continue response as soon as the application tries to read from the request body. In any way, all complete HTTP/1.1 implementations must somehow support that.

1

u/agentoutlier Jul 27 '22

Dude I know how important it is. I filed a bug on at least two frameworks that didn’t have it turned on:

https://github.com/jooby-project/jooby/issues/2363

So I’m well aware.

The other one was a netty lib that I just can’t find the bug for.

All I was saying that if the damn author wants to keep the core code base small they can do similar.

But yeah thanks for the mansplaining of HTTP and spec semantics. You might have as well included the link for me because I’m too dense: https://datatracker.ietf.org/doc/html/rfc2119

2

u/0x256 Jul 27 '22

This is a public discussion, so please don't feel personally attacked just because I explained something you might already know.

I explained the 100-continue flow to show that it might be a good idea to pass the final decision to the application and that application developers might benefit from this protocol feature, if it is exposed to them. This in turn explains why low-level libraries like Undertow or Netty let you control their behavior in such a great detail and not just hide the complexity and automatically handle everything for you. Undertow still fully supports 100-continue, and Netty does too. That was my point. Do you disagree?

→ More replies (0)