Join GitHub today
Rack SPEC doc unclear to me, help? #347
These are all related to http://rack.rubyforge.org/doc/SPEC.html
On Feb 28, 2012, at 8:34 AM, Jordan Sissel wrote:
It is implicitly specified by saying that "The environment must be an instance of Hash that includes CGI-like headers". The reasoning behind this: Environment variables may not contain underscores and are usually upper case. Moreover, headers are case insensitive. Note that Rack is designed to also work well with CGI.
I don't think it has to be a line, though that's convention.
"gets must be called without arguments and return a string, or nil on EOF."
I think each could even yield indefinite, though most middleware assumes otherwise. This includes middleware and tools that ship with Rack and are used by major frameworks and libraries. Most servers fix this by either passing in a real IO object or a StringIO.
Rewind to the beginning of the request. Yes, this makes a few things complicated. Also, you might do best simply not to use Rack for WebSockets. Most parts for Rack (including Rack::Request) assume that it can read the complete request and for instance parse params from it. Moreover, it assumes that it can read the complete request more than once, which is crucial at the moment, as Rack does not come with a sufficient reflection API to figure out whether some middleware somewhere already read from the stream or not.