All, I was asked a question by Andre Nathan and I took the liberty of
responding here so everyone can see it.
Here''s the code Andre is using to access the headers in an HTTP request
processed by the eventmachine_httpserver library:
module EventMachine::HttpServer
def http_headers
headers = {}
@http_headers.split(/\0/).each do |header|
name, val = header.split(/:\s*/, 2)
headers[name] = val
end
headers
end
end
As I recall, something similar to this code appears in comments or test
cases for the library. The reason this is not done by default is for
performance, because parsing HTTP headers is extremely costly and worthless
if you''re not going to do anything with them.
I''d be in favor of adding some extra code to the library to do header
parsing on demand, or lazily, or only for specific headers and not for all
of them. Any ideas?
Separately, I started experimenting this weekend with a pure-Ruby HTTP
protocol handler and was surprised to find that performance isn''t bad.
With
proper optimizations it might prove to be a good alternative. It turns out
that most of the performance impact comes from the network handling, which
EM already solves.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/eventmachine-talk/attachments/20071112/dd6bf42a/attachment.html