On 6/13/12 10:08 PM, Dalton Barreto wrote: > 2012/6/13 Jeff Van Voorst<[email protected]>: >> Hello, >> > Hello Jeff! > >> I am looking to use mongrel2 with SSL. I would like to add a field to >> the headers sent to the handlers notifying them whether or not the >> connection is using SSL. My reason for doing this is for redirects the >> handler needs to know whether to use http or https when building the url. >> >> Is this best done using a filter or is there an easier way to notify a >> handler if redirects should be prefixed using https? It could be that >> one of the header fields already contains this information and I >> overlooked it. >> >> If a filter is a good choice, then can a header be added in a filter >> using something like hash_alloc_insert(req->headers, "USING_SSL", "true")? >> >> Also, for which state or states should the header be added (that is, for >> HTTP_REQ only or for additional states)? >> > Maybe it's not possible to implement with an filter. That's because a > filter (when changing state) has just a pointer to the current > Connection structure and looking at it you cannot distinguish if it > came from mongrel2' ssl or non-ssl socket. > > But in the other hand, this is an important feature that should be > included in mongrel2 core, I think. > > Currently, I don't have enough free time to implement this, but I > would be available to review the code and merge it back into mongrel2 > core. > > Thanks, > Ok, I will dig through the code a bit more. I don't know what if anything would break if an additional header was added with the tag "SSL" and took the value from the config (or respected the ssl or non-ssl socket, if that is a better option). In an ideal setting, nothing would break as handlers should ignore unknown header values. However, for some handlers with "evil premature optimizations", unknown tags could cause problems.
--Jeff Van Voorst
