How to enable the TCP_NODELAY socket option?
I'm looking for a way to set socket options at the TCP protocol or the socket level. I've found that when creating a socket there is a flag that controls if the SO_KEEPALIVE socket option is set at the socket level. This however is controlling only one specific option at a specific level. Net::HTTP for example enables TCP_NODELAY but it is in all cases and there isn't even a flag to control it.
A permalink to Net::HTTP code that enables TCP_NODELAY: https://github.com/ruby/ruby/blob/d8dbc2dcba43ff36221f6549205d2d4cf64b760c/lib/net/http.rb#L1671
Net::HTTP::Persistent gem enables TCP_NODELAY by default too: https://github.com/drbrain/net-http-persistent/blob/234f3b2c6a0ed044e3c55e3de982257b4860ba0a/lib/net/http/persistent.rb#L519-L520