FeedTools

Daniel Sheppard daniels at pronto.com.au
Tue Sep 27 22:38:20 EDT 2005


Hmmm... poking about with feedtools, there doesn't seem to be a way to
make it parse a string rather than going to a URL.

No problems - MouseHole needs to be intercepting requests and subverting
them without necessarily visiting the requested URL.

Basically, I'm looking at replacing a section of the proxy_service call,
and creating an "intercept" method. The problem is the interface for
this method - what parameters should it get? what should it need to be
returning? Looking at the source-code for proxy_service in Webrick, I'm
not quiet sure at what point I should be handing over to the
interceptor.

Options are:
	- rely on the interceptor to handle everything that
proxy_service handles - this gives complete control, but makes things
hard.
	- pass in the request, the path and the header - expect a
HTTPResponse back - probably the minimum you can do and still leave a
lot of control, but it requires a fair bit of work to get it back to the
existing level .
	- ???

for option 2, in order to intercept the request, and say - send it to a
slightly different path (ie. add some more query params), you need to
do:

intercept do |request, path, header|
        path << path.include? '?' : '&' : '?'
        path << "nostyle=true";
        http = Net::HTTP.new(request.uri.host, request.uri.port)
        http.start{
          case req.request_method
          when "GET"  then response = http.get(path, header)
          when "POST" then response = http.post(path, req.body || "",
header)
          when "HEAD" then response = http.head(path, header)
          else
            raise HTTPStatus::MethodNotAllowed,
              "unsupported method `#{req.request_method}'."
          end
        }	
end

A helper method might be useful to encapsulate that core functionality,
and let the script writer change the request,path & header before
passing them through (if that's what they want to do).

intercept do |request, path, header|
        path << path.include? '?' : '&' : '?'
        path << "nostyle=true";
        need_a_name_for_this_thing(request, path, header)
end


Any thoughts on the matter?



#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mousehole-scripters/attachments/20050928/fd35b828/attachment.htm


More information about the Mousehole-scripters mailing list