This is an experiment to run HTTP 103 (Early Hints) with Hanami.
On November 2015, during my keynote at Ruby Day, I announced experimental support for HTTP/2 Push Promise with Lotus (the former name of Hanami). For the sake of the demo, I created this app: https://github.com/jodosha/instants.
During that summer, I started to experiment with HTTP/2 and Ruby: Rack and all the web servers weren't ready for it. So I had to write my own HTTP/2 Rack web server: https://github.com/jodosha/panther.
Fast forwarding to today: HTTP/2 is still not supported by Ruby ecosystem, but in the meantime IETF standardized HTTP 103 (Early Hints)
as of October 2017.
At the same time, Puma started to support it.
The next Hanami release (v1.2.0
), will include support for HTTP 103 (Early Hints)
.
- Git
- Ruby 2.3+ (with OpenSSL)
- h2o (
brew install h2o
)
% git clone https://github.com/jodosha/hall_of_fame.git
% cd hall_of_fame
% bin/setup
Start the project with one of the following methods, then visit https://localhost:9090/.
If you use foreman (or an alternative) run:
% foreman start
If you don't use foreman, you can start the project manually. Open two terminal windows:
% bundle exec hanami server
% h2o -c config/h2o.conf
If you want to debug the headers, please run:
% curl -i -v http://localhost:2300/
You should see something similar to this:
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 2300 (#0)
> GET / HTTP/1.1
> Host: localhost:2300
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 103 Early Hints
HTTP/1.1 103 Early Hints
< Link: </assets/hanami.png>; rel=preload; as=image
Link: </assets/hanami.png>; rel=preload; as=image
< Link: </assets/application.css>; rel=preload; as=style
Link: </assets/application.css>; rel=preload; as=style
< Link: </assets/jquery.min.js>; rel=preload; as=script
Link: </assets/jquery.min.js>; rel=preload; as=script
< Link: </assets/mansonry.min.js>; rel=preload; as=script
Link: </assets/mansonry.min.js>; rel=preload; as=script
< Link: </assets/application.js>; rel=preload; as=script
Link: </assets/application.js>; rel=preload; as=script
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
# Rest of the response headers and body..
© 2018 - Luca Guidi https://lucaguidi.com